Skip to main content

Crate openraft

Crate openraft 

Source
Expand description
OpenRaft

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.

§Feature flags

Openraft supports several feature flags to customize functionality:

Default features: tokio-rt

Runtime:

  • tokio-rt - Enable Tokio async runtime support (default)
  • single-threaded - Disallow sharing Raft instance across threads

Serialization:

  • serde - Add serde::Serialize and serde::Deserialize bounds to data types

Error handling:

  • bt - Enable error backtraces (requires nightly Rust)

Development:

  • bench - Enable benchmarks in unit tests (requires RUSTC_BOOTSTRAP=1 with stable Rust)

Compatibility:

  • compat - Provide basic compatible types for upgrades
  • type-alias - Enable openraft::alias::* type shortcuts (unstable)

§Openraft Document

If you’re starting to build an application with Openraft, check out

For an overview of Openraft’s capabilities and their APIs, see

To maintain an Openraft cluster, e.g., add or remove nodes, refer to

When upgrading an Openraft application, consult:

To learn about the data structures used in Openraft and the commit protocol, see

Contributors who want to understand the internals of Openraft can find relevant information in

Finally, the archived and discarded documents:

Re-exports§

pub extern crate openraft_macros as macros;
pub extern crate openraft_macros;
pub extern crate openraft_rt as rt;

Re-exports§

pub use errors as error;
pub use type_config::async_runtime;
pub use self::storage::LogState;
pub use self::storage::RaftLogReader;
pub use self::storage::RaftSnapshotBuilder;
pub use self::storage::Snapshot;
pub use self::storage::SnapshotMeta;
pub use self::storage::StorageHelper;
pub use crate::base::OptionalSerde;
pub use crate::entry::Entry;
pub use crate::entry::EntryPayload;
pub use crate::log_id::LogId;
pub use crate::log_id::LogIdOptionExt;
pub use crate::log_id::LogIndexOptionExt;
pub use crate::membership::Membership;
pub use crate::membership::StoredMembership;
pub use crate::metrics::RaftMetrics;
pub use crate::network::RPCTypes;
pub use crate::network::RaftNetwork;Deprecated
pub use crate::network::RaftNetworkFactory;
pub use crate::network::RaftNetworkV2;
pub use crate::raft::Precondition;
pub use crate::raft::Raft;
pub use crate::raft::ReadPolicy;
pub use crate::raft::WatchChangeHandle;
pub use crate::raft::linearizable_read::LinearizerOption;
pub use crate::type_config::RaftTypeConfig;
pub use crate::vote::Vote;
pub use anyerror;

Modules§

base
Basic types and traits with optional feature support.
batch
A container that stores elements efficiently by avoiding heap allocation for single elements.
compat
This mod is an upgrade helper that provides functionalities for a newer openraft application to read data written by an older application.
docs
Openraft Document
entry
Log entry types and traits.
errors
Error types exposed by this crate.
impls
Default implementations for common Openraft traits.
log_id
Log identification and comparison.
membership
Cluster membership configuration and management.
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 applications.
type_config
Define the configuration of types used by the Raft, such as NodeId, log Entry, etc.
vote
Election and voting types.

Macros§

declare_raft_types
Define types for a Raft type configuration.

Structs§

AnyError
AnyError is a serializable wrapper Error.
BasicNode
An implementation of the Node trait that contains minimal node information.
Config
Runtime configuration for a Raft node.
EmptyNode
EmptyNode is an implementation of the Node trait that contains nothing.
Extensions
A type-map for storing user-defined extension data.
MembershipState
The state of membership configs a raft node needs to know.
NodeInfo
An implementation of the Node trait that contains a Raft address and user-defined data.
RaftState
A struct used to represent the raft state which a Raft node needs.
SnapshotSegmentIdDeprecated
REMOVED: Use openraft_legacy::network_v1::SnapshotSegmentId instead.
StorageError
Error that occurs when operating the store.
TokioInstant
TokioRuntime
Tokio is the default asynchronous executor.

Enums§

ChangeMembers
Defines various actions to change the membership, including adding or removing learners or voters.
ConfigError
Error variants related to configuration.
ErrorSubject
The subject of a storage error, indicating what operation or component failed.
ErrorVerb
What it is doing when an error occurs.
ServerState
All possible states of a Raft node.
SnapshotPolicy
Log compaction and snapshot policy.
StepDownPolicy
Policy for stepping down a Leader that is removed from a committed membership config.

Traits§

AppData
A trait defining application-specific data.
AppDataResponse
A trait defining application-specific response data.
AsyncRuntime
A trait defining interfaces with an asynchronous runtime.
Instant
A measurement of a monotonically non-decreasing clock.
MessageSummary
Convert a type T to string.
Node
A Raft Node, this trait holds all relevant node information.
NodeId
A Raft node’s ID.
OptionalSend
A trait that is empty if the single-threaded feature flag is enabled, otherwise it extends Send.
OptionalSync
A trait that is empty if the single-threaded feature flag is enabled, otherwise it extends Sync.
ToStorageResult
Convert error to StorageError::IO();
TryAsRef
Similar to AsRef<T>, it does a cheap reference-to-reference conversion, but with the ability to return None if it is unable to perform the conversion to &T.
WatchSender
Sends values to the associated Receiver.

Type Aliases§

SnapshotId
Id of a snapshot stream.
StorageIOErrorDeprecated
Backward compatible with old application using StorageIOError

Attribute Macros§

add_async_trait
This proc macro attribute optionally adds Send bounds to a trait.