Skip to content

Commit 65b69f7

Browse files
committed
[server] add unitdb cluster
1 parent 1b3eb79 commit 65b69f7

File tree

18 files changed

+3054
-1917
lines changed

18 files changed

+3054
-1917
lines changed

NOTICE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,10 @@ hash/consistent.go
3030
hash/consistent_test.go
3131
hash/modulo.go
3232
hash/rand.go
33+
34+
-------------------------------------------------
35+
Unitdb includes derived work from tinode/chat under the GNU GPL v3.0. (https://github.com/tinode/chat/blob/master/LICENSE)
36+
37+
The derived work can be found in the files:
38+
server/internal/cluster.go
39+
server/internal/cluste_leaderr.go

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ Unitdb supports Get, Put, Delete operations. It also supports encryption, batch
3535

3636
Samples are available in the examples directory for reference.
3737

38+
## Clustering
39+
To bring up the Unitdb cluster start 2 or more nodes, 3 nodes or more nodes are recommended for fault tolerance.
40+
41+
$ ./bin/unitdb -listen=:6060 -grpc_listen=:6080 -cluster_self=one -db_path=/tmp/unitdb/node1
42+
$ ./bin/unitdb -listen=:6061 -grpc_listen=:6081 -cluster_self=two -db_path=/tmp/unitdb/node2
43+
44+
Above example shows each Unitdb node running on the same host, so each node must listen on different ports. This would not be necessary if each node ran on a different host.
45+
3846
## Architecture Overview
3947
The unitdb engine handles data from the point put request is received through writing data to the physical disk. Data is compressed and encrypted (if encryption is set) then written to a WAL for immediate durability. Entries are written to memdb and become immediately queryable. The memdb entries are periodically written to log files in the form of blocks.
4048

examples/pubsub/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var f unitdb.MessageHandler = func(client unitdb.Client, msg unitdb.Message) {
1717

1818
func main() {
1919
client, err := unitdb.NewClient(
20-
"grpc://localhost:6061",
20+
"grpc://localhost:6080",
2121
"UCBFDONCNJLaKMCAIeJBaOVfbAXUZHNPLDKKLDKLHZHKYIZLCDPQ",
2222
unitdb.WithInsecure(),
2323
unitdb.WithKeepAlive(2*time.Second),

0 commit comments

Comments
 (0)