Expand description
Openraft
§API status
Openraft API is currently unstable.
Incompatibilities may arise in upgrades prior to 1.0.0
.
Refer to our Change-Log for details.
Upgrade Guides explains how to upgrade.
Each commit message begins with a keyword indicating the type of change:
DataChange:
Changes to on-disk data types, possibly requiring manual upgrade.Change:
Introduces incompatible API changes.Feature:
Adds compatible, non-breaking new features.Fix:
Addresses bug fixes.
§Openraft Document
If you’re starting to build an application with Openraft, check out
To maintain an Openraft cluster, e.g., add or remove nodes, refer to
cluster_control
:cluster_formation
describes how to form a cluster;dynamic membership
describes how to add or remove nodes without downtime;node lifecycle
describes the transition of a node’s state;
When upgrading an Openraft application, consult:
To learn about the data structures used in Openraft and the commit protocol, see
feature_flags
;data
:Vote
is the core in a distributed system;Log pointers
shows how Openraft tracks entries in the log;Leader lease
explains leader lease for a Leader and a Follower;Extended membership
explains how members are organized in Openraft;Effective membership
explains when membership config takes effect;
components
explains the components in Openraft;RaftStateMachine
is the core API for managing the state machine and snapshot functionalities;
protocol
:
Contributors who want to understand the internals of Openraft can find relevant information in
internal
:- Architecture shows the overall architecture of Openraft;
- Threading describes the threading model of Openraft;
Finally, the archived and discarded documents:
obsolete
describes obsolete design documents and why they are discarded;
Re-exports§
pub extern crate openraft_macros;
pub use crate::async_runtime::AsyncRuntime;
pub use crate::async_runtime::TokioRuntime;
pub use crate::entry::Entry;
pub use crate::entry::EntryPayload;
pub use crate::instant::Instant;
pub use crate::instant::TokioInstant;
pub use crate::log_id::LogId;
pub use crate::log_id::LogIdOptionExt;
pub use crate::log_id::LogIndexOptionExt;
pub use crate::log_id::RaftLogId;
pub use crate::metrics::RaftMetrics;
pub use crate::network::RPCTypes;
pub use crate::network::RaftNetwork;
pub use crate::network::RaftNetworkFactory;
pub use crate::raft::Raft;
pub use crate::storage::LogState;
pub use crate::storage::RaftLogReader;
pub use crate::storage::RaftSnapshotBuilder;
pub use crate::storage::Snapshot;
pub use crate::storage::SnapshotMeta;
pub use crate::storage::StorageHelper;
pub use crate::type_config::RaftTypeConfig;
pub use anyerror;
Modules§
- async_
runtime async
runtime interface.- compat
- This mod is a upgrade helper that provides functionalities for a newer openraft application to read data written by an older application.
- docs
- Openraft Document
- entry
- The default log entry type that implements
RaftEntry
. - error
- Error types exposed by this crate.
- impls
- Collection of implementations of usually used traits defined by Openraft
- instant
- A trait for time instants.
- log_id
- This mod defines the identity of a raft log and provides supporting utilities to work with log id related types.
- metrics
- Raft metrics for observability.
- network
- The Raft network interface.
- raft
- Public Raft interface and data types.
- storage
- The Raft storage interface and data types.
- testing
- Testing utilities for OpenRaft.
- type_
config - Define the configuration of types used by the Raft, such as
NodeId
, logEntry
, etc.
Macros§
- declare_
raft_ types - Define types for a Raft type configuration.
Structs§
- AnyError
- AnyError is a serializable wrapper
Error
. - Basic
Node - An implementation of trait
Node
that contains minimal node information. - Config
- The runtime configuration for a Raft node.
- Defensive
Error - An error that occurs when the RaftStore impl runs defensive check of input or output. E.g. re-applying an log entry is a violation that may be a potential bug.
- Effective
Membership - The currently active membership config.
- Empty
Node - EmptyNode is an implementation of trait
Node
that contains nothing. - Leader
Id - LeaderId is identifier of a
leader
. - Membership
- The membership configuration of the cluster.
- Membership
State - The state of membership configs a raft node needs to know.
- Raft
State - A struct used to represent the raft state which a Raft node needs.
- Snapshot
Segment Id - The identity of a segment of a snapshot.
- StorageIO
Error - Error that occurs when operating the store.
- Stored
Membership - This struct represents information about a membership config that has already been stored in the raft logs.
- Vote
Vote
represent the privilege of a node.
Enums§
- Change
Members - Defines various actions to change the membership, including adding or removing learners or voters.
- Config
Error - Error variants related to configuration.
- Error
Subject - Error
Verb - What it is doing when an error occurs.
- Server
State - All possible states of a Raft node.
- Snapshot
Policy - Log compaction and snapshot policy.
- Storage
Error - A storage error could be either a defensive check error or an error occurred when doing the actual io operation.
- Violation
- Violations a store would return when running defensive check.
Traits§
- AppData
- A trait defining application specific data.
- AppData
Response - A trait defining application specific response data.
- Message
Summary - Node
- A Raft
Node
, this trait holds all relevant node information. - NodeId
- A Raft node’s ID.
- Optional
Send - Optional
Sync - ToStorage
Result - Convert error to StorageError::IO();
- TryAs
Ref - Similar to
AsRef<T>
, it does a cheap reference to reference conversion, but with the ability to returnNone
if it is unable to perform the conversion to&T
.
Type Aliases§
- Committed
Leader Id - The unique identifier of a leader that is already granted by a quorum in phase-1(voting).
- Snapshot
Id - Id of a snapshot stream.
Attribute Macros§
- add_
async_ trait - This proc macro attribute optionally adds
Send
bounds to a trait.