pub struct FileDriver { /* private fields */ }Implementations§
Source§impl FileDriver
impl FileDriver
Sourcepub fn open_or_init(dir: impl AsRef<Path>) -> Result<Arc<Self>, FileDriverError>
pub fn open_or_init(dir: impl AsRef<Path>) -> Result<Arc<Self>, FileDriverError>
Open the state directory. Creates it if missing. Reads and validates the
state file if present. Single-node deployments serve Leader { epoch: 0 }
continuously.
Acquires an exclusive OS-level lock on the LOCK sentinel file under
dir before reading state, and holds it for the lifetime of the
returned driver. A second concurrent open_or_init against the same
directory returns FileDriverError::AlreadyLocked immediately —
FileDriver enforces its one-writer-per-directory precondition rather
than trusting the operator to. The lock is released by the kernel when
the driver is dropped or the process exits (including crash).
Sourcepub fn init_seeded(
dir: impl AsRef<Path>,
seed_physical_ms: u64,
) -> Result<(), FileDriverError>
pub fn init_seeded( dir: impl AsRef<Path>, seed_physical_ms: u64, ) -> Result<(), FileDriverError>
Seed a fresh state directory with a high-water value. Used by the init
CLI subcommand for migrations. Fails if state already exists.
The stored high-water is a physical_ms (the same units the allocator
uses for committed_high_water), NOT a packed Timestamp. The seed
argument is interpreted as the maximum physical_ms ever observed in the
prior system; on first serve, the failover fence will advance above it.
Trait Implementations§
Source§impl ConsensusDriver for FileDriver
impl ConsensusDriver for FileDriver
Source§fn leadership_events(&self) -> Pin<Box<dyn Stream<Item = LeaderState> + Send>>
fn leadership_events(&self) -> Pin<Box<dyn Stream<Item = LeaderState> + Send>>
Source§fn load_high_water<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, ConsensusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn load_high_water<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, ConsensusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn persist_high_water<'life0, 'async_trait>(
&'life0 self,
at_least: u64,
_epoch: Epoch,
) -> Pin<Box<dyn Future<Output = Result<u64, ConsensusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn persist_high_water<'life0, 'async_trait>(
&'life0 self,
at_least: u64,
_epoch: Epoch,
) -> Pin<Box<dyn Future<Output = Result<u64, ConsensusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
at_least. Returns the
actual durably-persisted value, which is max(stored_value, at_least). Read moreSource§fn load_dense_seq<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 SeqKey,
) -> Pin<Box<dyn Future<Output = Result<u64, ConsensusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_dense_seq<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 SeqKey,
) -> Pin<Box<dyn Future<Output = Result<u64, ConsensusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
load_high_water. Default: unsupported.Source§fn advance_dense<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 SeqKey,
count: u32,
_expected_epoch: Epoch,
) -> Pin<Box<dyn Future<Output = Result<u64, ConsensusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn advance_dense<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 SeqKey,
count: u32,
_expected_epoch: Epoch,
) -> Pin<Box<dyn Future<Output = Result<u64, ConsensusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
seq[key] += count and returns the pre-advance value
as the block start. expected_epoch fences a stale proposer. Default:
unsupported.Source§fn advance_dense_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
entries: &'life1 [(SeqKey, u32)],
_expected_epoch: Epoch,
) -> Pin<Box<dyn Future<Output = Result<Vec<u64>, ConsensusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn advance_dense_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
entries: &'life1 [(SeqKey, u32)],
_expected_epoch: Epoch,
) -> Pin<Box<dyn Future<Output = Result<Vec<u64>, ConsensusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
(key, count) and
returns the per-key pre-advance block starts in request order. All-or-
nothing — a cardinality or overflow rejection advances no key. Lazily
creates absent keys at 0. expected_epoch fences a stale proposer.
Default: unsupported.Source§fn load_leases<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<LeaseRecord>, ConsensusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn load_leases<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<LeaseRecord>, ConsensusError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
load_high_water: the returned set must
reflect every lease write durably committed before this call started,
from any prior leader at any prior epoch. Default: unsupported.