Expand description
openraft
Raft is not yet good enough. This project intends to improve raft as the next generation consensus protocol for distributed data storage systems (SQL, NoSQL, KV, Streaming, Graph … or maybe something more exotic).
The guide is the best place to get started.
Openraft is derived from async-raft with several bugs fixed: Fixed bugs.
A full list of changes/fixes can be found in change-log
Features
-
It is fully reactive and embraces the async ecosystem. It is driven by actual Raft events taking place in the system as opposed to being driven by a
tick
operation. Batching of messages during replication is still used whenever possible for maximum throughput. -
Storage and network integration is well defined via two traits
RaftStorage
&RaftNetwork
. This provides applications maximum flexibility in being able to choose their storage and networking mediums. -
All interaction with the Raft node is well defined via a single public
Raft
type, which is used to spawn the Raft async task, and to interact with that task. The API for this system is clear and concise. -
Log replication is fully pipelined and batched for optimal performance. Log replication also uses a congestion control mechanism to help keep nodes up-to-date as efficiently as possible.
-
It fully supports dynamic cluster membership changes with joint config. The buggy single-step membership change algo is not considered. See the
dynamic membership
chapter in the guide. -
Details on initial cluster formation, and how to effectively do so from an application’s perspective, are discussed in the cluster formation chapter in the guide.
-
Automatic log compaction with snapshots, as well as snapshot streaming from the leader node to follower nodes is fully supported and configurable.
-
The entire code base is instrumented with tracing. This can be used for standard logging, or for distributed tracing, and the verbosity can be statically configured at compile time to completely remove all instrumentation below the configured level.
Contributing
Check out the CONTRIBUTING.md guide for more details on getting started with contributing to this project.
License
Openraft is licensed under the terms of the MIT License or the Apache License 2.0, at your choosing.
Feature flags
bt
: Enable backtrace: generate backtrace for errors. This requires a unstable featurebacktrace
thus it can not be used with stable rust, unless explicity allowing using unstable features in stable rust withRUSTC_BOOTSTRAP=1
.
Re-exports
pub use anyerror;
pub use async_trait;
pub use crate::config::Config;
pub use crate::config::SnapshotPolicy;
pub use crate::error::ChangeMembershipError;
pub use crate::error::ClientWriteError;
pub use crate::error::ConfigError;
pub use crate::error::InitializeError;
pub use crate::error::RaftError;
pub use crate::error::ReplicationError;
pub use crate::metrics::RaftMetrics;
pub use crate::raft::Raft;
pub use crate::types::v065::AppData;
pub use crate::types::v065::AppDataResponse;
pub use crate::types::v065::AppendEntriesRequest;
pub use crate::types::v065::AppendEntriesResponse;
pub use crate::types::v065::DefensiveError;
pub use crate::types::v065::EffectiveMembership;
pub use crate::types::v065::Entry;
pub use crate::types::v065::EntryPayload;
pub use crate::types::v065::ErrorSubject;
pub use crate::types::v065::ErrorVerb;
pub use crate::types::v065::HardState;
pub use crate::types::v065::InitialState;
pub use crate::types::v065::LogId;
pub use crate::types::v065::Membership;
pub use crate::types::v065::NodeId;
pub use crate::types::v065::RaftNetwork;
pub use crate::types::v065::RaftStorage;
pub use crate::types::v065::RaftStorageDebug;
pub use crate::types::v065::Snapshot;
pub use crate::types::v065::SnapshotId;
pub use crate::types::v065::SnapshotMeta;
pub use crate::types::v065::SnapshotSegmentId;
pub use crate::types::v065::StateMachineChanges;
pub use crate::types::v065::StorageError;
pub use crate::types::v065::StorageIOError;
pub use crate::types::v065::Violation;
Modules
Raft runtime configuration.
Error types exposed by this crate.
Raft metrics for observability.
Public Raft interface and data types.
Structs
AnyError is a serializable wrapper Error
.
Extended store backed by another impl.
Enums
Traits
Defines methods of defensive checks for RaftStorage.
A wrapper extends the APIs of a base RaftStore.