MIT Licensed
No CLAs
100% Community Guided
New Contributor Friendly
Questions Welcome
(Even during the talk!)
☹ (Currently) Nightly Only & Not on Crates.io
@danburkert, @james-darkfox, @tschottdorf
@ongardie, @carllerche, @dwrensha,
#rust@irc.mozilla.org
A few finals later...
Not just a key/value store! Build what you need.
Raft-rs represents more of an RPC and replication framework than a database or cache.
// Create a Client associated with a cluster.
let mut client = raft::Client::new(cluster);
// Passes through durable log, is committed, may mutate state machine.
let prop_res = client.propose(msg);
// Immutable access to state machine.
let query_res = client.query(msg);
// Spawn a server. This will block the current thread as long as it's running.
Server::run(id, addr, peers, persistent_log, state_machine).unwrap();
Represents the replicated, persistent log of your application.
Has a strong ordering such that A → B → C and should only act to store information.
Entries placed into the log should not be acted on by the consuming application.
Generally not application specific.
Help us make some cool ones?
/// Returns the latest known term.
fn current_term(&self) -> result::Result<Term, Self::Error>;
/// Sets the current term to the provided value. The provided term must be greater than
/// the current term. The `voted_for` value will be reset`.
fn set_current_term(&mut self, term: Term) -> result::Result<(), Self::Error>;
/// Increment the current term. The `voted_for` value will be reset.
fn inc_current_term(&mut self) -> result::Result<Term, Self::Error>;
/// Returns the candidate id of the candidate voted for in the current term (or none).
fn voted_for(&self) -> result::Result<Option<ServerId>, Self::Error>;
/// Sets the candidate id voted for in the current term.
fn set_voted_for(&mut self, server: ServerId) -> result::Result<(), Self::Error>;
/// Returns the index of the latest persisted log entry (0 if the log is empty).
fn latest_log_index(&self) -> result::Result<LogIndex, Self::Error>;
/// Returns the term of the latest persisted log entry (0 if the log is empty).
fn latest_log_term(&self) -> result::Result<Term, Self::Error>;
/// Returns the entry at the provided log index.
fn entry(&self, index: LogIndex) -> result::Result<(Term, &[u8]), Self::Error>;
/// Appends the provided entries to the log beginning at the given index.
fn append_entries(&mut self, from: LogIndex, entries: &[(Term, &[u8])]) -> result::Result<(), Self::Error>;
/// Applies a command to the state machine.
/// Returns an application-specific result value.
fn apply(&mut self, command: &[u8]) -> Vec<u8>;
/// Queries a value of the state machine. Does not go through the durable log, or mutate the
/// state machine.
/// Returns an application-specific result value.
fn query(&self, query: &[u8]) -> Vec<u8>;
/// Take a snapshot of the state machine.
fn snapshot(&self) -> Vec<u8>;
/// Restore a snapshot of the state machine.
fn restore_snapshot(&mut self, snapshot: Vec<u8>) -> ();
1.0 should represent a full implementation of Diego's Paper.
Help us:
Find us on: