EzRaft
A beginner-friendly Raft consensus framework built on OpenRaft.
Run your application on several machines at once, all holding the same state, so the
service survives losing some of them. That is what Raft is
for, and EzRaft reduces it to two traits: EzApp holds your state and applies requests
to it, EzStorage puts bytes on disk. Elections, replication, membership, snapshots and
the transport between machines are handled internally.
- Minimal user API: 4 methods total (3 storage + 1 app) vs 21+ in OpenRaft
- Smart defaults: 10/12 Raft types pre-configured, users specify only Request/Response
- Built-in networking: HTTP layer included, no user code needed
- Type-safe: Works directly with your types, not byte vectors
Example
A replicated key-value service, whole. FileStorage is the bundled EzStorage, so the
application is all that is left to write:
/// The application *is* the replicated state: a snapshot is this struct, serialized.
/// One binary, run once per machine: `kvstore <own-addr> [addr of a node already in it]`
async
Three of those form a cluster that survives losing any one of them:
Drive it
# A write goes through the log: replicated and committed before it answers.
# null - Set answers with the value it replaced, if there was one
# A read is answered from that node's own memory: no consensus round, no log entry.
# "world" - from a node you never wrote to
Status
Experimental. EzRaft is primarily an API design laboratory for exploring intuitive interface patterns. The APIs may change until the crate stabilizes. Production applications are not the primary audience.
Next phase: Stable API. Once the design exploration matures, EzRaft will provide a stable API with well-considered abstractions - exposing what users need while hiding unnecessary complexity.
Documentation
- Guide - run a cluster, write a service against it, and the API, configuration and HTTP endpoints that make it up
- API documentation
examples/kvstore.rs- a complete key-value service- CHANGELOG
License
Licensed under either of Apache-2.0 or MIT, at your option.