GithubHelp home page GithubHelp logo

tempbottle / raft-rs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from johnmq/raft-rs

0.0 2.0 0.0 504 KB

Raft implementation in Rust

License: MIT License

Ruby 1.75% Makefile 0.03% Rust 98.21%

raft-rs's Introduction

Raft-rs Build Status

Raft consensus algorithm implementation in Rust language as a reusable library.

You can read about Raft consensus algorithm here: raftconsensus.github.io. It is very simple to understand and is a very powerful tool to use.

Part of the JohnMQ Project - High-performance, persistent, reliable and dumb-simple messaging queue in Rust.

Disclaimer

This project is still under heavy development and lack key features and therefore is not recommended for production usage. Missing features:

  • It is not working, yet. But first iteration is almost over, and after that it may be used with caution.

Contributions are highly welcome. And by the way, I'm looking for collaborators to make this project production ready faster. Email me if you feel like: [email protected]

Usage

NOTE: Work in progress.

This project is powered by cargo.

Clone & build the project:

git clone https://github.com/johnmq/raft-rs.git
cd raft-rs
cargo build

Optionally check that tests are passing (since your version of rustc could be incompatible with current version of raft-rs):

cargo test               # to run the same suite that is run on travis
cargo test -- --bench    # if you want to run benchmarks

Usage as library

NOTE: Work in progress.

raft-rs is build as library. So you can install raft-rs in your regular Cargo project by adding this to your Cargo.toml:

[dependencies.raft_rs]

git = "https://github.com/johnmq/raft-rs.git"

Exposed abstractions (traits)

It exposes a bunch of traits that can be implemented and injected back into raft_rs to make it work in your domain:

// use raft_rs::intercommunication::Intercommunication;
pub trait Intercommunication < T: Committable + Send + Show > {
    fn new() -> Self;
    fn register(&mut self, host: String) -> Endpoint < T >;
    fn receive(&mut self) -> Option < Package < T > >;
    fn send(&mut self, recipient: String, package: Package < T >);
    fn is_debug(&self) -> bool;
}

// use raft_rs::replication::{Committable, Receivable, Queriable, LogPersistence, ReplicationLog};
pub trait Committable { }
pub trait Receivable { }
pub trait Queriable { }
pub trait LogPersistence < T: Committable > {
    fn commit(&self, entry: T) -> io::IoResult < () >;
}
pub trait ReplicationLog < T: Committable, Q: Queriable, R: Receivable > {
    fn new() -> Self;

    fn len(&self) -> uint;
    fn committed_offset(&self) -> uint;
    fn commit_upto(&mut self, new_committed_offset: uint) -> io::IoResult < () >;
    fn discard_downto(&mut self, new_len: uint) -> io::IoResult < () >;

    fn autocommit_if_safe(&mut self, majority_size: uint);

    fn enqueue(&mut self, entry: T) -> io::IoResult < uint >;
    fn persisted(&mut self, offset: uint, node: String) -> io::IoResult < uint >;
    fn query_persistance(&mut self, query: Q, respond_to: Sender < R >);
}

TODO: example how to implement these traits and how to inject them back into raft_rs.

Further examples

TODO: put simple implementation examples in examples/ folder and link to it from here.

Contributing

  1. Fork it https://github.com/johnmq/raft-rs/fork
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am "Add some feature")
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

raft-rs's People

Contributors

waterlink avatar

Watchers

 avatar  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.