Skip to content

Commit 37127c4

Browse files
authored
Merge pull request #6 from tjarkpr/dev
Version 1.0.1
2 parents 41c8774 + ad18bf6 commit 37127c4

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
## *🕸️ MqttDistribNet* - A structured distribution network for amqp messaging
2+
3+
The MqttDistribNet module consist of two concepts, to ease the usage of amqp brokers:
4+
- **Dynamic Infrastructure Management**<br>
5+
To simplify the configuration of topics and queues and binding them in a logical path,
6+
we introduced an <code>IDistributionNetworkManager</code> and <code>IRemoteDistributionNetworkManager</code>.
7+
While the <code>IDistributionNetworkManager</code> is the infrastructure management server, the <code>IRemoteDistributionNetworkManager</code>
8+
is used by the client to get information about the remote managed infrastructure.
9+
- **Simple Message Distribution**<br>
10+
Based on Request/Response and Publish/Subscribe Patterns we created <code>Handler</code>, <code>Consumer</code> and <code>Clients</code> to easily
11+
configure the wanted behaviour behind queues and reach them by their configured message type.
12+
13+
### 1. Usage:
14+
```go
15+
import (
16+
mqttdistribnet "github.com/tjarkpr/mqttdistribnet/pkg"
17+
amqp "github.com/rabbitmq/amqp091-go"
18+
)
19+
```
20+
#### 1.1. DistributionNetworkManager
21+
```go
22+
connection, err := amqp.Dial(url)
23+
manager, err := mqttdistribnet.MakeIDistributionNetworkManager(connection, "<prefix>")
24+
logs, err := manager.Start(&ctx)
25+
```
26+
#### 1.2. Distribution & Consumption
27+
```go
28+
connection, err := amqp.Dial(url)
29+
remote, err := mqttdistribnet.MakeIRemoteDistributionNetworkManager(connection, "<prefix>")
30+
```
31+
```go
32+
remote.Register(reflect.TypeFor[mqttdistribnet.Envelope[TestRequest]](), "L1.L2.L3.L4.*")
33+
```
34+
```go
35+
err = mqttdistribnet.MakeRequestHandler[mqttdistribnet.Envelope[TestRequest], mqttdistribnet.Envelope[TestResponse]](
36+
remote,
37+
func(request mqttdistribnet.Envelope[TestRequest]) (mqttdistribnet.Envelope[TestResponse], error) {
38+
t.Log("Request: " + request.ToString())
39+
return mqttdistribnet.Envelope[TestResponse]{
40+
MessageId: uuid.New(),
41+
Timestamp: time.Now(),
42+
Payload: TestResponse{TestResProperty: "Test"},
43+
}, nil
44+
}, &ctx)
45+
```
46+
```go
47+
request := &mqttdistribnet.Envelope[TestRequest]{
48+
MessageId: uuid.New(),
49+
Timestamp: time.Now(),
50+
Payload: TestRequest{TestReqProperty: "Test"},
51+
}
52+
clients, err := mqttdistribnet.MakeRequestClient[mqttdistribnet.Envelope[TestRequest], mqttdistribnet.Envelope[TestResponse]](remote)
53+
response, err := slices.Collect(maps.Values(clients))[0].Send(request)
54+
```

tests/mqttdistrib_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/testcontainers/testcontainers-go/modules/rabbitmq"
99
mqttdistribnet "github.com/tjarkpr/mqttdistribnet/pkg"
1010
"maps"
11-
"
1211
"reflect"
1312
"slices"
1413
"testing"

0 commit comments

Comments
 (0)