Simple
This example creates a member per process, where each member joins the
cluster, periodically updates its local state with random entries, and logs
the received updates.
Running
Create a member per process with flags:
-addr
: Address to listen on
-join
: Addresses of existing members to join
Such as to create a three node cluster:
go run examples/simple/main.go -addr :7000
go run examples/simple/main.go -addr :7001 -join localhost:7000
go run examples/simple/main.go -addr :7002 -join localhost:7000
Each member will gracefully leave the cluster on SIGINT
or SIGTERM
signals.
You can also forcefully terminate a node with SIGKILL
which won't leave
gracefully but exits immediately so the other nodes will detect it as failed.
To expose Prometheus metrics, configure the metrics server address with
-metrics-addr
. This will expose the Prometheus metrics at
http://{addr}/metrics
.