Skip to main content

Crate yggr

Crate yggr 

Source
Expand description

Jotun — a Raft node runtime built on yggr_core.

Users implement StateMachine (your application’s apply/restore logic) and call Node::start; the runtime owns the engine, the network transport, the on-disk persistence, the tick driver, and the action dispatcher. Incoming snapshots are installed and restored automatically. By default the runtime also reacts to snapshot hints from the engine by calling StateMachine::snapshot and feeding the resulting bytes back into Raft; the serializer runs on a separate task so a slow StateMachine::snapshot does not stall ticks, heartbeats, or Node::status. snapshot is fallible (SnapshotError); returning Err just skips this hint and the engine retries on the next one. Set Config::snapshot_hint_threshold_entries to 0 (and Config::max_log_entries) if you want to disable host-initiated compaction entirely.

Observability is pull-model: Node::metrics returns a snapshot of counters and gauges covering elections, replication, commits, applies, reads, and snapshots.

For users who want different transport, storage, or concurrency, Storage and Transport are traits — the defaults are TCP + a hand-rolled segmented log on disk, but anything that satisfies the trait works.

Internals (the engine state machine, log entries, message types) live in yggr_core and are re-exported here for convenience.

Re-exports§

pub use node::Bootstrap;
pub use node::Config;
pub use node::ConfigError;
pub use node::Node;
pub use node::NodeStartError;
pub use node::NodeStatus;
pub use node::ProposeError;
pub use node::ReadError;
pub use node::Role;
pub use node::TransferLeadershipError;
pub use state_machine::DecodeError;
pub use state_machine::SnapshotError;
pub use state_machine::StateMachine;
pub use storage::DiskStorage;
pub use storage::DiskStorageError;
pub use storage::Storage;
pub use storage::StoredHardState;
pub use storage::StoredSnapshot;
pub use transport::TcpTransport;
pub use transport::TcpTransportError;
pub use transport::Transport;

Modules§

node
The user-facing Node runtime: a long-running task that owns the engine and dispatches its actions.
state_machine
The trait users implement to plug their application logic into a crate::Node.
storage
Trait for the on-disk side of a crate::Node.
transport
Trait for the network side of a crate::Node.

Structs§

LogIndex
Position of an entry in the replicated log.
NodeId
A unique identifier for a node in the Raft cluster.
Term
Logical clock for the cluster (§5.1).

Enums§

ConfigChange
A cluster-membership change carried by a LogPayload::ConfigChange log entry.