❯ go test ./...
❯ go build
Alternatively, if you choose to build the proto files
❯ ./scripts/build.sh
❯ # ./scripts/clean-create.sh num_nodes
❯ ./scripts/clean-create.sh 5
❯ # ./scripts/spawn.sh num_nodes is_bootstrap
❯ ./scripts/spawn.sh 5 true
Here the spawn.sh
script accepts the number of nodes to spawn and true specifies if we should start in bootstrap mode. Bootstrap mode is necessary only when starting the cluster for the first time.
❯ # ./scripts/join.sh num_nodes
❯ ./scripts/join.sh 5
This script uses curl
command to request the node1
to accept node2
, node3
, node4
and node5
as followers.
❯ # ./scripts/status.sh num_nodes
❯ ./scripts/status.sh 5
| No | Leader | Host:Port | Health |
|----+--------+----------------+--------|
| 1 | ✅ | 127.0.0.1:8001 | 🟢 |
| 2 | | 127.0.0.1:8002 | 🟢 |
| 3 | | 127.0.0.1:8003 | 🟢 |
| 4 | | 127.0.0.1:8004 | 🟢 |
| 5 | | 127.0.0.1:8005 | 🟢 |
Health and status checks completed for 5 nodes.
This script uses jq
command to format json output.
If you check the cluster status before forming a cluster, you will find that all the nodes we spawned are leaders in bootstrap mode
slot_per_node_count
: Specify the number of slots per node. This will decide the slots in each node to create the DHT. Required only for the first time.
❯ # ./scripts/configure.sh slot_per_node_count
❯ ./scripts/configure.sh 4
pkill -f ./timeMachine