Code Monkey home page Code Monkey logo

raft-1's Introduction

libraft
=======

Raft protocol implementation in C.

Features
--------

+ Leader Election
+ Log Replication
+ Log Compaction

Usage
-----

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 check

TODO
----

+ Membership Changes

raft-1's People

Contributors

kelvich avatar knizhnik avatar kvap avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.