Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nanne007/raft.ex
Rafting. See -------> http://raft.github.io
https://github.com/nanne007/raft.ex
Last synced: 8 days ago
JSON representation
Rafting. See -------> http://raft.github.io
- Host: GitHub
- URL: https://github.com/nanne007/raft.ex
- Owner: nanne007
- License: mit
- Created: 2016-05-17T09:05:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-12-14T20:58:25.000Z (almost 5 years ago)
- Last Synced: 2023-07-13T19:50:51.828Z (over 1 year ago)
- Language: Elixir
- Homepage:
- Size: 51.8 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Raft
Raft Protocol Implementation in Elixir.
**WIP**
Currently, the first step(leader-election) is done.
One can use the following to see the result.``` elixir
# in one iex shell,
{:ok, server} = Raft.start_consensus_server({:server1, :"server1@localhost"}, [server1: :"server1@localhost", server2: :"server2@localhost"])# and another.
{:ok, server} = Raft.start_consensus_server({:server2, :"server2@localhost"}, [server1: :"server1@localhost", server2: :"server2@localhost"])
```and use `server |> Raft.Supervisor.get_consensus() |> :sys.get_state()`
to get the instant state of each.Here is the result on my mac:
``` elixir
{:leader,
%Raft.Consensus{commit_index: 0, config: #PID<0.2035.0>, current_term: 11,
last_applied: 0, log: #PID<0.2036.0>,
match_indexes: %{{:server2, :server2@localhost} => 0},
me: {:server1, :server1@localhost}, meta: nil,
next_indexes: %{{:server2, :server2@localhost} => 1},
timer: #Reference<0.0.3.7630>, voted_for: {:server1, :server1@localhost},
voter_log: %{}, votes_granted: #MapSet<[server2: :server2@localhost]>,
votes_responded: #MapSet<[server2: :server2@localhost]>}}
# and another
{:follower,
%Raft.Consensus{commit_index: 0, config: #PID<0.1110.0>, current_term: 11,
last_applied: 0, log: #PID<0.1111.0>, match_indexes: %{},
me: {:server2, :server2@localhost}, meta: nil, next_indexes: %{},
timer: #Reference<0.0.4.4728>, voted_for: {:server1, :server1@localhost},
voter_log: %{}, votes_granted: #MapSet<[]>, votes_responded: #MapSet<[]>}}
```### Contribute
Ping me by Issue and PR!