Skip to main content

FileDriver

Struct FileDriver 

Source
pub struct FileDriver { /* private fields */ }

Implementations§

Source§

impl FileDriver

Source

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).

Source

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

Source§

fn leadership_events(&self) -> Pin<Box<dyn Stream<Item = LeaderState> + Send>>

Stream of leadership transitions. The server holds this for its lifetime. Read more
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,

Read the durably-persisted high-water. Read more
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,

Durably advance the high-water to at least at_least. Returns the actual durably-persisted value, which is max(stored_value, at_least). Read more
Source§

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,

Read a key’s durably-committed dense counter (0 if absent). Linearized, like 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,

Durable, linearized fetch-add for one key. Lazily creates the key at 0 on first use. Commits 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,

Atomic, linearized multi-key fetch-add: advances each (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,

Read the durably-committed lease set. Linearized, like 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.
Source§

fn persist_leases<'life0, 'life1, 'async_trait>( &'life0 self, live: &'life1 [LeaseRecord], _epoch: Epoch, ) -> Pin<Box<dyn Future<Output = Result<(), ConsensusError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Durably replace the full live lease set, atomically. Read more
Source§

impl Debug for FileDriver

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.