tsoracle-driver-openraft
ConsensusDriver implementation for tsoracle backed by openraft via tsoracle-openraft-toolkit.
What it provides
OpenraftDriver— thetsoracle_consensus::ConsensusDriverimpl. Wraps anopenraft::Rafthandle and the bundledHighWaterStateMachine; bridges them to tsoracle'sleadership_events,load_high_water, andpersist_high_watercontract.OpenraftHighWaterHost— the single trait a host service implements to expose its openraft cluster to the driver. Lets a service share one raft log between its own state and the tsoracleHighWaterCommand.StandaloneHost— turnkeyOpenraftHighWaterHostfor services that don't already run openraft. Bring yourRaftLogStorageandRaftNetworkFactory; this crate provides the state machine and the trait bridge.HighWaterStateMachine— theRaftStateMachineimpl over an in-memoryu64high-water counter. Snapshots use postcard via a pluggableSnapshotStore(in-memory default, plus an optionalRocksdbSnapshotStorebehind therocksdb-snapshot-storefeature).HighWaterCommand— the typed log entry the driver injects into the host's raft log.- The
RaftTypeConfig(viatsoracle_openraft_toolkit::declare_raft_types_ext!) —TypeConfigand friends.
Patterns
Standalone services
Greenfield path — wire StandaloneHost::new(raft, state_machine) with an openraft::Raft handle you constructed against tsoracle_openraft_toolkit::RocksdbLogStore plus your own RaftNetworkFactory, then hand the resulting OpenraftDriver to Server::builder().consensus_driver(driver). See examples/openraft-standalone for the full wiring with a tonic peer transport.
Piggyback on an existing openraft
If your service already runs an openraft for its own state, implement OpenraftHighWaterHost directly against that handle. HighWaterCommand becomes a tagged variant of your application command type, decided on the same log alongside your own commands; one snapshot covers both halves. See examples/openraft-piggyback for the worked envelope pattern.
Feature flags
rocksdb-snapshot-store(default) — enablesRocksdbSnapshotStore, keyed in a caller-managed RocksDB column family. Pairs naturally withtsoracle_openraft_toolkit::RocksdbLogStoreso oneArc<DB>covers both the raft log and the persisted snapshot. Disable withdefault-features = falseif you want a custom snapshot backend.
Documentation
docs/consensus-integration.md— theConsensusDrivertrait reference, the "Choosing a driver" comparison (file vs openraft vs paxos), and the canonical worked example for the openraft side.tsoracle-openraft-toolkit— the reusable openraft glue this crate is built on (RocksDB log store,declare_raft_types_ext!macro, lifecycle helpers).