Closed psvensson closed 1 year ago
No, StateMachineWriter is being used by the raft log to write to the StateMachine from the log file.
What you are looking for probably is how to append data to the raft log.
The most straightforward way is to use the RequestUpdate RPC message (see PROTO.md).
There are several tools here that helps with this task, (raft.client.*).
Use one of the client classes: e.g. raft.client.ZmqRaftClient
and lookup the method requestUpdate
.
You can also play with the raft cli: npx run cli
. But that's already in the README.
Fair enough, I'm going to add some examples to README anyway.
Thank you. I was of course after an as simple as possible example of how to use it practically (both getting and sending logs). I'll start looking at the update method of aft.client.ZmqRaftClient but will hold an eye out for an update README as well :+1:
Ok, here they are. I hope this clears up a bit.
There is also a new "Use Cases" section to exemplify how I'm using ZmqRaft depending on the application type.
I also bumped version to 0.5.0 with the small change to ZmqRaftSubscriber and some latest commits from a contributor.
That was indeed very helpful. Thank you!
While on the subject of bumping, I noticed that there is no npm package yet for zmq-raft. I have solved that by using a git link in my package.json, but I think it also would be helpful
I haven't really felt the need to publish it to npmjs before. However I don't see a reason why not and since you requested it, here you go: https://www.npmjs.com/package/zmq-raft
Please let me know if it works for you.
It worked very well, thank you. Now it's easier to discover for people just searching for something raft on npm. Much easier than a git link, for sure
Hi again, I forgot to ask one thing. I would like advice on how to write to state. There seems to be a couple of options but I'm unsure what would be the best one. I see that there is a StateMachineWriter class, which looks like a good candidate, but apart from providing the extisting StateMachine instance in the constructor, itä' not apparent how to provide the other arguments;constructor(stateMachine, firstIndex, currentTerm, snapshot) {...
Is this the right way to go, or is there another perhaps simpler way to add user data to the logs?