https://github.com/postgrespro/raft
Raft protocol implementation in C
https://github.com/postgrespro/raft
Last synced: 6 days ago
JSON representation
Raft protocol implementation in C
- Host: GitHub
- URL: https://github.com/postgrespro/raft
- Owner: postgrespro
- License: bsd-2-clause
- Created: 2016-03-11T16:06:36.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-08-10T12:54:26.000Z (over 8 years ago)
- Last Synced: 2025-04-24T10:48:43.523Z (7 days ago)
- Language: C
- Size: 63.5 KB
- Stars: 51
- Watchers: 34
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: LICENSE
Awesome Lists containing this project
README
libraft
=======Raft protocol implementation in C.
Features
--------+ Leader Election
+ Log Replication
+ Log CompactionUsage
-----1. Include raft.h and link with -lraft
2. Initialize:
a. Populate a ``raft_config_t`` with parameters (host, port, timeouts,
log length, etc.)b. Set an applier and a snapshooter callbacks. The applier should
perform state modification, and the snapshooter should dump the state.
See raft.h for their signatures.c. Call raft_init(cfg).
d. Use raft_peer_up(...) to configure the peers, including the current
one.e. Create and bind the socket with raft_create_udp_socket(...).
3. Serve raft:
a. Call raft_tick(...) frequently to perform the logic of timeouts.b. Try to extract a message with raft_recv_message(...) when you
believe there is one in the socket.c. Call raft_handle_message(...) when a message has been successfully
extracted from the socket.4. Serve clients:
a. If this server is a leader (call raft_get_leader(...) to find out),
then it should accept pending connections and process client quieries.b. Use raft_emit(...) to update the state though raft. Then wait until
raft_applied(...) before returning the result to the client.c. You may use raft_get_leader(...) to redirect clients to the leader,
though this is not necessary.Please read raft.h and example/ for more details.
Testing
-------1. Install docker and blockade.
2. You may want to gain superuser privileges at this point.
3. $ make checkTODO
----+ Membership Changes