You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,11 @@ Make use of the client by importing it in your Go client source code. For exampl
33
33
34
34
Unitdb supports Get, Put, Delete operations. It also supports encryption, batch operations, and writing to wildcard topics. See [usage guide](https://github.com/unit-io/unitdb/tree/master/docs/usage.md).
35
35
36
-
Samples are available in the examples directory for reference.
36
+
Samples are available in the examples directory for reference. To build unitdb client from latest source code use "replace" in go.mod to point to your local module.
37
+
38
+
```golang
39
+
go mod edit -replace github.com/unit-io/unitdb-go=$GOPATH/src/github.com/unit-io/unitdb-go
40
+
```
37
41
38
42
## Clustering
39
43
To bring up the Unitdb cluster start 2 or more nodes. For fault tolerance 3 nodes or more are recommended.
@@ -44,13 +45,15 @@ An application transport the data by uTP across network, it contains payload dat
44
45
### Client
45
46
A Client opens the network connection to the Server using TCP/IP, WebSocket, GRPC or other bi-direction network protocols.
46
47
- Pubslihes Application Mesasges to a topic that other Clients subscribes to.
48
+
- Sends a relay request to retrieve persisted Application Messages from Server.
47
49
- Subscribes to a topic to receive Application Messages.
48
50
- Unsubcribe to remove a topic subscription.
49
51
- Closes the network connection to the Server.
50
52
51
53
### Server
52
54
- Accepts the network connections from Clients.
53
55
- Recieves and store Application Messages published by Clients.
56
+
- Relays pesisted Application Messages that matches the relay requests from Clients.
54
57
- Processes topic subscription requests from Clients.
55
58
- Route Application Messages that match Client subscriptions.
56
59
- Closes the network connection from the Client.
@@ -75,24 +78,25 @@ Represented as enum value, the values are shown below.
75
78
| RERSERVED | 0 | Forbidden |
76
79
| CONNECT | 1 | Client to Server |
77
80
| PUBLISH | 2 | Client to Server or Server to Client |
78
-
| SUBSCRIBE | 3 | Client to Server |
79
-
| UNSUBSCRIBE | 4 | Client to Server |
80
-
| PINGREQ | 5 | Client to Server |
81
-
| DISCONNECT | 6 | Client to Server or Server to Client |
81
+
| RELAY | 3 | Client to Server |
82
+
| SUBSCRIBE | 4 | Client to Server |
83
+
| UNSUBSCRIBE | 5 | Client to Server |
84
+
| PINGREQ | 6 | Client to Server |
85
+
| DISCONNECT | 7 | Client to Server or Server to Client |
82
86
83
87
### Flow Control
84
88
Flow Control is Control Message sent in response to a uTP Message Type or another Control Message.
85
89
86
-
Client will send one of Message Type CONNECT, SUBSCRIBE, UNSUBSCRIBE, or PINGREQ then Server will reponse with ACKNOWLEDGE Control Message. PUBLISH Message is sent from a Client to a Server or from a Server to a Client and if Delivery Mode is Express Delivery then the receiver will respond with ACKNOWLEDGE Control Message.
90
+
Client will send one of Message Type CONNECT, RELAY, SUBSCRIBE, UNSUBSCRIBE, or PINGREQ then Server will reponse with ACKNOWLEDGE Control Message. PUBLISH Message is sent from a Client to a Server or from a Server to a Client and if Delivery Mode is Express Delivery then the receiver will respond with ACKNOWLEDGE Control Message.
87
91
88
92
| Name | Value | Direction of Flow |
89
93
| :--- | :--- | :--- |
90
94
| None | 0 | None |
91
95
| ACKNOWLEDGE | 1 | Client to Server or Server to Client |
92
96
| NOTIFY | 2 | Server to Client |
93
97
| RECEIVE | 3 | Client to Server |
94
-
| RECEIPT | 4 | Client to Server or Server to Client |
95
-
| COMPLETE | 5 |Client to Server or Server to Client |
98
+
| RECEIPT | 4 | Client to Server |
99
+
| COMPLETE | 5 | Server to Client |
96
100
97
101
### Message Length
98
102
The Message Length represents number of bytes within the current Message.
@@ -106,7 +110,8 @@ In order to implement a Reliable Message Delivery flow the Client and Server nee
106
110
The Server persists an unique Session State per Client Identifier. Client can also specify Sesson Key during Connection to persist multiple Session States per Client Identifier. The Session can continue after network re-connection until Client specify Clean Session during a new Connection.
107
111
108
112
The Client Session pesist following States:
109
-
- Reliable and Batch Delivery messages sent to the Server, but have not been completely acknowledged.
113
+
- Reliable and Batch Delivery messages sent to the Server, but have not been acknowledged.
114
+
- Relay request sent to the Server, but have not been acknowledged.
110
115
- Reliable and Batch Delivery messages which have been received from the Server, but have not been completely acknowledged.
111
116
112
117
The Server Session persiste following states:
@@ -278,6 +283,26 @@ The PublishMessage contains folowing fields:
278
283
### TTL
279
284
A publisher can specify time to-live (TTL) when publishing an Application Message.
280
285
286
+
### RELAY - Relay request
287
+
The RELAY Message is sent from the Client to the Server to get persisted Application Messages from server for one or more topics. Each Relay request pairs the topics with last durations. The Server sends PUBLISH Messages to the Client to forward Application Messages that were persisted by the Server for the Topics that match these Relay requests. The RELAY Message also specifies (for each request) the Last duration for which the Server can send persisted Application Messages to the Client.
288
+
289
+
The payload contains following fields.
290
+
291
+
| Name | Type |
292
+
| :--- | :--- |
293
+
| MessageID | int32 |
294
+
| RelayRequests | repeated RelayRequest |
295
+
296
+
The RelayRequest contains folowing fields:
297
+
298
+
| Name | Type |
299
+
| :--- | :--- |
300
+
| Topic | string |
301
+
| Last | string |
302
+
303
+
#### Last
304
+
A Client can specify Last duration (for example "1h") to retrive persisted Application Messages published to the Topic.
305
+
281
306
### SUBSCRIBE - Subscribe request
282
307
The SUBSCRIBE Message is sent from the Client to the Server to create one or more Subscriptions. Each Subscription registers one or more Topics for a Client. The Server sends PUBLISH Messages to the Client to forward Application Messages that were published to Topics that match these Subscriptions. The SUBSCRIBE Message also specifies (for each Subscription) the Delivery Mode with which the Server can send Application Messages to the Client.
283
308
@@ -295,10 +320,7 @@ The Subscription contains folowing fields:
295
320
| DeliveryMode | int32 |
296
321
| Delay | int32 |
297
322
| Topic | string |
298
-
| Last | string |
299
323
300
-
#### Last
301
-
A Subscriber can spcify Last duration (for example "1h") to retrive persisted Application Messages published to the subscribing Topic.
302
324
303
325
### UNSUBSCRIBE - Unsubscribe request
304
326
An UNSUBSCRIBE Message is sent by the Client to the Server, to unsubscribe from topics.
@@ -320,7 +342,7 @@ The DISCONNECT Message is the final uTP Message sent from the Client or the Serv
320
342
321
343
## Control Message
322
344
### ACKNOWLEDGE - acknowledgement
323
-
The ACKNOWLEDGE Control Message is sent by the Server in response to CONNECT, SUBSCRIBE, UNSUBSCRIBE, PUBLISH or PINGREQ Message from a Client.
345
+
The ACKNOWLEDGE Control Message is sent by the Server in response to CONNECT, RELAY, SUBSCRIBE, UNSUBSCRIBE, PUBLISH or PINGREQ Message from a Client.
324
346
325
347
The ACKNOWLEGE Message on CONNECT is sent with Message in the form of binary data that contains below Payload inforation.
326
348
@@ -358,11 +380,9 @@ The Server must send a NOTIFY Control Message containing a new Message Identifie
358
380
The Client must send a RECEIVE Control Message to respond to the NOTIFY Control Message to tell Server it is ready to receive the message. It must contain the same Message Identifier from NOTIFY Control Message.
359
381
360
382
### RECEIPT - Publish receipt
361
-
The Server must respond with RECEIPT Control Message if it receive a PUBLISH Message with Delivery Mode as RELIABLE or BATCH Delivery.
362
-
363
383
The Client must respond to a PUBLISH Message with a RECEIPT Control Message if it has a matching subscription with Delivery Mode RELIABLE or BATCH Delivery and sender has sent a PUBLISH Message with RELIABLE or BATCH Delivery Mode.
364
384
365
385
The RECEIPT Control Message must contain the same Message Identifier from PUBLISH Message.
366
386
367
387
### COMPLETE - Publish complete
368
-
The Client or the Server must respond with COMPLETE Control Message if it receives a RECEIPT Control Message to mark the Publish complete. The COMPLETE Control Message must contain the same Message Identifier from RECEIPT Control Message.
388
+
The Server must respond with COMPLETE Control Message if it receives a RECEIPT Control Message from Client to mark the Publish complete. The COMPLETE Control Message must contain the same Message Identifier from RECEIPT Control Message.
0 commit comments