WIP: Add raft example
This PR add standalone raft example
resolves https://github.com/etcd-io/raft/issues/2
This PR supersedes https://github.com/etcd-io/raft/pull/67
The refactor commits are cherrypicked from https://github.com/Elbehery/raft/pull/1/commits
cc @mhagger @ahrtr
@serathius @pav-kv @ahrtr
i have added the wal and its deps from etcd repo, i know that this should be standalone without any deps.
however, the raft example requires wal. I need suggestions how to proceed
same issue exist with rafthttp.Transport.
@Elbehery Do you intend the example to be a fully-functional server with a fully-functional storage, and run each node in a different process?
My sense is that, for example purposes, you can cut corners, and make Storage and transport simple and in-memory. For example, you can use MemoryStorage from this repo. For implementing transport between nodes, you can take some inspiration from tests. All nodes can be in the same process, and transport can shuffle messages from one in-memory node to another.
I.e. things like wal are probably not needed.
Also, what kind of state-machine/commands do you want to support? I think it can also be super-simple, like a single-value register with a put and/or conditional-put command. Doesn't need to be a fully-fledged key-value store.
I think a much smaller example can be started up from taking code snippets in the README, and putting them together to work. It can be done gradually, for instance you don't need to support config changes in the first version.
@Elbehery Do you intend the example to be a fully-functional server with a fully-functional storage, and run each node in a different process?
My sense is that, for example purposes, you can cut corners, and make
Storageand transport simple and in-memory. For example, you can useMemoryStoragefrom this repo. For implementing transport between nodes, you can take some inspiration from tests. All nodes can be in the same process, and transport can shuffle messages from one in-memory node to another.
Thanks @pav-kv for your comment
I actually also agree to keep it simple since it is an example. However, I think the example should at least have each raft node in a separate process iiuc
wdyt @ahrtr @serathius ?