-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ring: working example on using
ring
package (#272)
* build local memberlist ring based on loopback Signed-off-by: Kaviraj <[email protected]> * working local setup Signed-off-by: Kaviraj <[email protected]> * remove vendor Signed-off-by: Kaviraj <[email protected]> * Adding simple cluster to read peers in the ring Signed-off-by: Kaviraj <[email protected]> * Client using helpers Signed-off-by: Kaviraj <[email protected]> * cleanup Signed-off-by: Kaviraj <[email protected]> * Combine into single `local.go` with modes. Update README Signed-off-by: Kaviraj <[email protected]> * Add memberlist state page image Signed-off-by: Kaviraj <[email protected]> * go mod tidy Signed-off-by: Kaviraj <[email protected]> * Update ring/example/local/README.md Co-authored-by: Arve Knudsen <[email protected]> * Update ring/example/local/README.md Co-authored-by: Arve Knudsen <[email protected]> * Update ring/example/local/README.md Co-authored-by: Arve Knudsen <[email protected]> * Update ring/example/local/README.md Co-authored-by: Arve Knudsen <[email protected]> * Update ring/example/local/local.go Co-authored-by: Arve Knudsen <[email protected]> * Update ring/example/local/local.go Co-authored-by: Arve Knudsen <[email protected]> * Update ring/example/local/local.go Co-authored-by: Arve Knudsen <[email protected]> * `go mod tidy` Signed-off-by: Kaviraj <[email protected]> * PR remarks Signed-off-by: Kaviraj <[email protected]> --------- Signed-off-by: Kaviraj <[email protected]> Co-authored-by: Arve Knudsen <[email protected]>
- Loading branch information
Showing
9 changed files
with
1,315 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
## Build local cluster using `Ring` | ||
|
||
This examples uses `loopback` interface to build a ring of multiple processes locally. | ||
|
||
### Usage | ||
|
||
1. Build | ||
``` | ||
go build local.go | ||
``` | ||
|
||
2. Start a peer | ||
|
||
``` | ||
./local -bindaddr=127.0.0.1 | ||
``` | ||
|
||
3. Start another peer in different terminal | ||
|
||
``` | ||
./local -bindaddr=127.0.0.2 -join-member=127.0.0.1 | ||
``` | ||
|
||
4. You can start as many peers as you want with different loopback bindaddr. | ||
|
||
5. Check the ring page | ||
|
||
Go to ring page of one of the peers. Each peer's ring page should show all the peers in the ring. Should look something like below. | ||
|
||
e.g: http://127.0.0.1:8100/ring | ||
|
||
![Ring Status Page](./images/local-ring.png) | ||
|
||
6. Also check the memberlist status page. | ||
|
||
e.g: https://127.0.0.1:8100/kv | ||
|
||
![Memberlist Status Page](./images/local-memberlist.png) | ||
|
||
7. You can also get the `ring` information as a client. | ||
|
||
``` | ||
./local -mode=client | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
module github.com/grafana/dskit/ring/example/local | ||
|
||
go 1.19 | ||
|
||
require ( | ||
github.com/go-kit/log v0.2.1 | ||
github.com/grafana/dskit v0.0.0-00010101000000-000000000000 | ||
github.com/prometheus/client_golang v1.14.0 | ||
) | ||
|
||
require ( | ||
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect | ||
github.com/armon/go-metrics v0.3.10 // indirect | ||
github.com/beorn7/perks v1.0.1 // indirect | ||
github.com/cespare/xxhash/v2 v2.1.2 // indirect | ||
github.com/coreos/go-semver v0.3.0 // indirect | ||
github.com/coreos/go-systemd/v22 v22.4.0 // indirect | ||
github.com/fatih/color v1.13.0 // indirect | ||
github.com/go-logfmt/logfmt v0.5.1 // indirect | ||
github.com/gogo/googleapis v1.1.0 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/gogo/status v1.1.0 // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/golang/snappy v0.0.4 // indirect | ||
github.com/google/btree v1.0.1 // indirect | ||
github.com/hashicorp/consul/api v1.15.3 // indirect | ||
github.com/hashicorp/errwrap v1.0.0 // indirect | ||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect | ||
github.com/hashicorp/go-hclog v0.14.1 // indirect | ||
github.com/hashicorp/go-immutable-radix v1.3.0 // indirect | ||
github.com/hashicorp/go-msgpack v0.5.5 // indirect | ||
github.com/hashicorp/go-multierror v1.1.1 // indirect | ||
github.com/hashicorp/go-rootcerts v1.0.2 // indirect | ||
github.com/hashicorp/go-sockaddr v1.0.2 // indirect | ||
github.com/hashicorp/golang-lru v0.5.4 // indirect | ||
github.com/hashicorp/memberlist v0.3.1 // indirect | ||
github.com/hashicorp/serf v0.9.7 // indirect | ||
github.com/mattn/go-colorable v0.1.12 // indirect | ||
github.com/mattn/go-isatty v0.0.14 // indirect | ||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect | ||
github.com/miekg/dns v1.1.50 // indirect | ||
github.com/mitchellh/go-homedir v1.1.0 // indirect | ||
github.com/mitchellh/mapstructure v1.5.0 // indirect | ||
github.com/opentracing/opentracing-go v1.2.0 // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/prometheus/client_model v0.3.0 // indirect | ||
github.com/prometheus/common v0.37.0 // indirect | ||
github.com/prometheus/procfs v0.8.0 // indirect | ||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect | ||
github.com/sirupsen/logrus v1.8.1 // indirect | ||
github.com/uber/jaeger-client-go v2.28.0+incompatible // indirect | ||
github.com/uber/jaeger-lib v2.2.0+incompatible // indirect | ||
github.com/weaveworks/common v0.0.0-20230119144549-0aaa5abd1e63 // indirect | ||
github.com/weaveworks/promrus v1.2.0 // indirect | ||
go.etcd.io/etcd/api/v3 v3.5.0 // indirect | ||
go.etcd.io/etcd/client/pkg/v3 v3.5.0 // indirect | ||
go.etcd.io/etcd/client/v3 v3.5.0 // indirect | ||
go.uber.org/atomic v1.10.0 // indirect | ||
go.uber.org/multierr v1.6.0 // indirect | ||
go.uber.org/zap v1.17.0 // indirect | ||
golang.org/x/mod v0.6.0 // indirect | ||
golang.org/x/net v0.1.0 // indirect | ||
golang.org/x/sys v0.1.0 // indirect | ||
golang.org/x/text v0.4.0 // indirect | ||
golang.org/x/time v0.1.0 // indirect | ||
golang.org/x/tools v0.2.0 // indirect | ||
google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c // indirect | ||
google.golang.org/grpc v1.50.1 // indirect | ||
google.golang.org/protobuf v1.28.1 // indirect | ||
) | ||
|
||
replace github.com/hashicorp/memberlist => github.com/grafana/memberlist v0.3.1-0.20220714140823-09ffed8adbbe | ||
|
||
replace github.com/grafana/dskit => ../../../../dskit |
Oops, something went wrong.