hashicorp/raft

Raft client reference implementation

Opened this issue ยท 5 comments

Hello ๐Ÿ˜„
This is kind of related to #128, I have been working on an implementation of a cluster using this library and I'm now facing a difficulty: there is nowhere an example or an explanation of how to connect remotely to a cluster (either to the Leader or Follower) and send commands to it.
It should be possible, since the cluster members are talking to each other with Transport, but it's not so immediate to build.
Would it be ok to have an RPCClient reference implementation or some documentation on how to connect and send commands to a running Raft cluster?
I dug up a bit into Consul codebase ad could not really find it...
Thank you

Hello @xuyang2 thanks for the references ๐Ÿ˜„
I have implemented something similar with gRPC instead of HTTP; I'd rather avoid this in favour of connecting directly to the RPC service exposed by the raft nodes.
My take is: if nodes are communicating via a custom RPC protocol (which I think is briefly detailed in net_transport.go#L43), what do I need to have this same logic used by a client that wants to send some data to raft cluster? I'd probably need to call AppendEntries in the client to send some data to it?

If yes it would be great to have a reference implementation that can be used as part of the library here to build not only the server but also the client.

stale commented

Hey there,
We wanted to check in on this request since it has been inactive for at least 90 days.
Have you reviewed the latest godocs?
If you think this is still an important issue in the latest version of the Raft library or
its documentation please feel let us know and we'll keep it open for investigation.
If there is still no activity on this request in 30 days, we will go ahead and close it.
Thank you!

This is still valid IMO, checked the docs and still no sign of the reference implementation

Jille commented

I'd probably need to call AppendEntries in the client to send some data to it?

That is an internal method and having clients call it is going to break your cluster.

I wrote some example code: https://github.com/Jille/raft-grpc-example - it includes a server and client.

It uses https://github.com/Jille/raft-grpc-leader-rpc to allow you to easily send RPCs to your leader. Clients connect to all Raft nodes and use health checks to figure out who the leader is. Add in some retries and you don't have to think about it anymore :)