• Stars
    star
    266
  • Rank 149,592 (Top 4 %)
  • Language
    Rust
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[Incomplete] A Raft implementation in Rust

Raft-rs

Note: This project is of alpha quality. APIs are still in some flux, but they are ready for you to play with them. A stable version will be released when we feel it is ready.

Build Status Coverage Status

Development Updates

Problem and Importance

When building a distributed system one principal goal is often to build in fault-tolerance. That is, if one particular node in a network goes down, or if there is a network partition, the entire cluster does not fall over. The cluster of nodes taking part in a distributed consensus protocol must come to agreement regarding values, and once that decision is reached, that choice is final.

Distributed Consensus Algorithms often take the form of a replicated state machine and log. Each state machine accepts inputs from its log, and represents the value(s) to be replicated, for example, a hash table. They allow a collection of machines to work as a coherent group that can survive the failures of some of its members.

Two well known Distributed Consensus Algorithms are Paxos and Raft. Paxos is used in systems like Chubby by Google, and Raft is used in things like etcd. Raft is generally seen as a more understandable and simpler to implement than Paxos, and was chosen for this project for this reason.

Documentation

Compiling

For Linux, BSD, or Mac. Windows is not supported at this time. We are willing and interested in including support, however none of our contributors work on Windows. Your PRs are welcome!

You will need the Rust compiler:

curl -L https://static.rust-lang.org/rustup.sh > rustup
chmod +x rustup
./rustup --channel=nightly

We require the nightly channel for now.

This should install cargo and rustc. Next, you'll need capnp to build the messages.canpnp file . It is suggested to use the git method

git clone https://github.com/sandstorm-io/capnproto.git
cd capnproto/c++
./setup-autotools.sh
autoreconf -i
./configure
make -j6 check
sudo make install

Finally, clone the repository and build it:

git clone [email protected]:Hoverbear/raft-rs.git && \
cd raft-rs && \
cargo build

Note this is a library, so building won't necessarily produce anything useful for you unless you're developing.

Examples

You can run a single-node register example like this:

RUST_LOG=raft=debug cargo run --example register server 1 1 127.0.0.1:8080

There are currently examples showing:

  • Register: A single shared, replicated buffer for storing some data. Uses bincode.
  • Hashmap: A replicated hash table that stores json::Value with Strings as keys. Uses serde.

For a multi-node example (hashmap shown for variety), make sure to include all the peers on all instances:

# Node 1
RUST_LOG=raft=debug cargo run --example hashmap server 1 1 127.0.0.1:8080 2 127.0.0.1:8081
# Node 2
RUST_LOG=raft=debug cargo run --example hashmap server 2 1 127.0.0.1:8080 2 127.0.0.1:8081

We'd love it if you contributed your own or expanded on ours!

Testing

You can run the raft crate's full bank of tests with all debug output like so:

RUST_BACKTRACE=1 RUST_LOG=raft=debug cargo test -- --nocapture

For something more terse use cargo test.

Contributing

First timer with Git? Check this out for some help!!

We use Homu for merging requests. This means we cannot merge your code unless it passes tests!

More Repositories

1

digitalocean

A prototype API for Digital Ocean.
Rust
37
star
2

heroku-buildpack-rust

A Rust buildpack for Heroku!
Shell
34
star
3

docker-archlinux

Docker Baseimage script for Arch Linux
Shell
17
star
4

docker-rust

A Rust loaded docker image, suitable for using to build projects.
6
star
5

chaos-workshop

Surviving the Chaos: A Field Guide
Shell
6
star
6

CSC-446

CSC 446 for UVic, Winter 2015. Proff Ganti.
Java
6
star
7

transit

An attempt to track code moves over the life of a project.
JavaScript
4
star
8

tikv_client

A WIP Official TiKV Client for Rust.
Rust
4
star
9

https-terminator

Some Ansible scripts to set up a Digital Ocean box that terminates HTTPS.
3
star
10

calendar_queue

Rust
3
star
11

hoverbear.org

Sources for hoverbear.org
HTML
2
star
12

catalyst

Why yes I would like to make a unikernel.
Rust
2
star
13

booper

A pgx flake test/demo!
Nix
2
star
14

tikv-docker-stack

A Docker Stack for TiKV development & exploration. (Not for production!)
Shell
2
star
15

math-201-notes

IPython Notebooks from Math 201 in Spring 2013 at the University of Victoria
2
star
16

rust-education-paper

A paper about Rust and how it solves common bugs.
TeX
2
star
17

docker-persona

Shell
2
star
18

si

Rust
1
star
19

docker-funtoo

A base image for Funtoo.
Dockerfile
1
star
20

seng-265-projects

The project files for SENG 265 at the University of Victoria with Professor Michael Zastre in Winter 2012-2013. I received an A+ in the course.
C
1
star
21

CSC-320

CSC 320 for UVic, Winter 2015. Proff Kapron.
Makefile
1
star
22

example

Rust
1
star
23

termformat

A simple terminal text formatter.
Rust
1
star
24

scoop-devops-vm

A Vagrantfile with accompanying projects meant to provide a easy, clean demo or development environment.
Shell
1
star
25

CSC-361

CSC-361 for Fall 2013 at UVic.
C
1
star
26

CSC-475

Music Information Retrieval with George Tzanetakis.
Jupyter Notebook
1
star
27

CSC-225

Lab files for CSC 225 at uVic in Fall 2012.
C
1
star
28

CSC-226

Java project files for CSC-226.
Java
1
star