Skip to main content

DurableIoCore

Struct DurableIoCore 

Source
pub struct DurableIoCore<E, B, C, K>
where E: EpochId + 'static, K: StampClock,
{ /* private fields */ }
Expand description

dioring’s core: every lineage’s durability, the targets it decides for, the operations in flight or held for their gates, and the queue of entries for the consumer (DI-D-49). E is the epoch-id type, B the backend’s owned buffer, C the consumer’s per-operation context, and K the clock failures are stamped with.

Implementations§

Source§

impl<E, B, C, K> DurableIoCore<E, B, C, K>
where E: EpochId + 'static, K: StampClock,

Source

pub fn resolve( &mut self, items: Vec<(FailureToken, Resolution)>, ) -> Result<CoreActions<DioringIds<E, <K as StampClock>::Instant>, B>, ResolveError<DioringIds<E, <K as StampClock>::Instant>>>

Resolve failures, validated whole and applied together: a refused call changes nothing and hands every token back.

§Errors

ResolveError, naming why and handing back the tokens.

Source

pub fn import_failure( &mut self, scope: ImportScope<DioringIds<E, <K as StampClock>::Instant>>, ) -> Result<(Imported<DioringIds<E, <K as StampClock>::Instant>>, CoreActions<DioringIds<E, <K as StampClock>::Instant>, B>), UnknownLineage<DioringIds<E, <K as StampClock>::Instant>>>

Record a failure the consumer learned of outside the instance (DI-D-12 (h)), reaching the uncovered writes scope names.

§Errors

UnknownLineage for an ImportScope::Lineage that is not this core’s live one.

Source

pub fn failures( &self, ) -> Vec<FailureInfo<DioringIds<E, <K as StampClock>::Instant>>>

The unresolved failures, in observation order.

Source

pub fn take_token(&mut self, failure: FailureId) -> Option<FailureToken>

A new token for failure, if it is unresolved and its token was dropped.

Source§

impl<E, B, C, K> DurableIoCore<E, B, C, K>
where E: EpochId + 'static, K: StampClock,

Source

pub fn mint_lineage(&mut self, description: Option<String>) -> Lineage

Mint a lineage, described by description.

Source

pub fn lineages( &self, ) -> Vec<LineageInfo<DioringIds<E, <K as StampClock>::Instant>>>

The live lineages, in minting order, the default first.

Source

pub fn end_lineage( &mut self, lineage: Lineage, ) -> Result<CoreActions<DioringIds<E, <K as StampClock>::Instant>, B>, EndLineageRefusal<DioringIds<E, <K as StampClock>::Instant>>>

End lineage (DI-D-30): every epoch of it not yet durable is abandoned, a LineageEnded entry reports it, and every operation held by a gate on one of its epochs, or a held write of its own, completes as NeverIssued.

§Errors

EndLineageRefusal::Foreign for a lineage that is not this core’s live one, and EndLineageRefusal::Default for the default lineage.

Source

pub fn retire_lineage( &mut self, lineage: Lineage, ) -> Result<(), RetireLineageRefusal<DioringIds<E, <K as StampClock>::Instant>>>

Retire lineage if nothing holds it, so it is no longer enumerated (DI-D-40).

§Errors

RetireLineageRefusal::Foreign for a lineage that is not this core’s live one, RetireLineageRefusal::Default for the default lineage, and RetireLineageRefusal::Busy naming what still holds it.

Source§

impl<E, B, C, K> DurableIoCore<E, B, C, K>
where E: EpochId + 'static, K: StampClock,

Source

pub fn with_provider( clock: K, diagnostics: Arc<dyn DiagnosticSink>, domains: Vec<FlushDomain>, ) -> Result<DurableIoCore<E, B, C, K>, DuplicateDomain>

A core whose consumer’s provider serves domains, read once, as new builds one otherwise. A target declaring a domain it serves has that domain’s part of each seal answered by the provider; every other domain, and every target declared with none, is the built-in default’s commit.

§Errors

DuplicateDomain for a domain named twice.

Source

pub fn provided( &mut self, lineage: Lineage, seal: u64, domain: &FlushDomain, outcome: DomainOutcome, ) -> CoreActions<DioringIds<E, <K as StampClock>::Instant>, B>

The provider answered domain of lineage’s seal seal, as a ProviderRequest named them. An answer for a lineage since ended reports nothing, as a late commit does (DI-D-42).

An answer naming another core’s lineage, a domain the provider does not serve, a seal or domain no request asked about, or a domain answered twice is the driver or the provider breaking the protocol, and is panicked on (DI-D-44, DI-D-46).

Source§

impl<E, B, C, K> DurableIoCore<E, B, C, K>
where E: EpochId + 'static, K: StampClock,

Source

pub fn new( clock: K, diagnostics: Arc<dyn DiagnosticSink>, ) -> DurableIoCore<E, B, C, K>

A core with no targets, no provider, and only its default lineage, stamping failures with clock and reporting to diagnostics.

Source

pub fn default_lineage(&self) -> Lineage

The default lineage, which every core has and which never ends.

Source

pub fn add_target( &mut self, key: IoTargetKey, description: IoTargetDescription, ) -> Result<(), DuplicateTarget<IoTargetDescription>>

Decide for a target under key, as description states it. The driver attaches the target itself to the backend under the same key.

§Errors

DuplicateTarget, handing the description back, if key is in use.

Source

pub fn target(&self, key: IoTargetKey) -> Option<&IoTargetDescription>

The description of the target under key, if there is one.

Source

pub fn remove_target( &mut self, key: IoTargetKey, ) -> Result<IoTargetDescription, RemoveTargetError<DioringIds<E, <K as StampClock>::Instant>>>

Stop deciding for the target under key, handing its description back, unless something still holds it (DI-D-45). The driver detaches the target from the backend once this succeeds.

§Errors

RemoveTargetError::UnknownKey for no such target, and RemoveTargetError::Busy naming every hold at once: operations in flight, operations held for a gate, uncovered writes, and the failures suspecting writes to it.

Source

pub fn write<Bk>( &mut self, target: IoTargetKey, offset: u64, data: SubmissionData<B>, epoch: Epoch<DioringIds<E, <K as StampClock>::Instant>>, context: C, options: WriteOptions<DioringIds<E, <K as StampClock>::Instant>>, backend: &mut Bk, ) -> Result<OpId, PushError<DioringIds<E, <K as StampClock>::Instant>, B, C>>
where Bk: IoBackend<Buffer = B>,

Write data to target at offset, tagged epoch: checked, then held for its gate, or pushed to backend as a submission and recorded once the push accepts it. The caller submits.

§Errors

PushError, handing back the buffer (None for a registered region) and context: for an unknown target; an epoch whose lineage is not this core’s live one, at or below its seal point, or abandoned; a gate in another core, of a lineage not live, abandoned, or closing a cycle (DI-D-43) – checked in that order – or PushRefusal::Backend with the cause the backend gave: its check’s for a write the core would hold, its push’s for one pushed now.

Source

pub fn read<Bk>( &mut self, target: IoTargetKey, offset: u64, data: SubmissionData<B>, context: C, options: ReadOptions<DioringIds<E, <K as StampClock>::Instant>>, backend: &mut Bk, ) -> Result<OpId, PushError<DioringIds<E, <K as StampClock>::Instant>, B, C>>
where Bk: IoBackend<Buffer = B>,

Read from target at offset into data: checked, then held for its gate, or pushed to backend and recorded once the push accepts it. The caller submits.

§Errors

PushError, handing back the buffer and context: for an unknown target; a gate in another core, of a lineage not live, or abandoned; or PushRefusal::Backend with the cause the backend gave, as for write.

Source

pub fn make_durable_through( &mut self, through: Epoch<DioringIds<E, <K as StampClock>::Instant>>, ) -> Result<(DurabilityRequest<DioringIds<E, <K as StampClock>::Instant>>, CoreActions<DioringIds<E, <K as StampClock>::Instant>, B>), SealError<DioringIds<E, <K as StampClock>::Instant>>>

Seal every epoch of through’s lineage at or below it (DI-D-9): the answer, and what it made due at once.

§Errors

SealError::UnknownLineage for a lineage that is not this core’s live one, and SealError::GateCycle for a seal that would close a gate cycle (DI-D-43).

Source

pub fn complete( &mut self, completion: Completion<B>, ) -> CoreActions<DioringIds<E, <K as StampClock>::Instant>, B>

Record a completion the backend reported: a consumer operation’s entry goes on the queue before anything it makes due, so a Durable it leads to follows it (guarantee 5).

A completion for no submission in flight – one never handed out, or completed twice – is the backend breaking its contract, and is panicked on (DI-D-46, DI-D-50 P9).

Source

pub fn refused( &mut self, refused: Refused<B>, ) -> CoreActions<DioringIds<E, <K as StampClock>::Instant>, B>

Take back a submission the core originated that the backend refused (DI-D-54). For a retryable cause it is kept, and emitted again with the next actions or by retry; nothing is due. For any other it can never be issued, so it ends here, as a completion with a REFUSED fault would end it: an operation completes as Failed, a write nullified as one its target failed is, and a commit fails its seal’s flush of its target. What that makes due is returned.

A consumer operation the consumer’s push issued never comes back this way – its push is refused to the consumer – so one that does, or a submission never handed out, is panicked on (DI-D-46).

Source

pub fn retry( &mut self, ) -> CoreActions<DioringIds<E, <K as StampClock>::Instant>, B>

The submissions refused before, to push again – once the driver has submitted or drained, as their causes said.

Source

pub fn pop( &mut self, ) -> Option<Entry<DioringIds<E, <K as StampClock>::Instant>, B, C>>

The next entry, if there is one.

Source

pub fn durable_through( &self, lineage: Lineage, ) -> Result<Option<E>, UnknownLineage<DioringIds<E, <K as StampClock>::Instant>>>

The lineage’s high-water mark: the highest epoch reported durable, or None if none is.

§Errors

UnknownLineage for a lineage that is not this core’s live one.

Source

pub fn sealed_through( &self, lineage: Lineage, ) -> Result<Option<E>, UnknownLineage<DioringIds<E, <K as StampClock>::Instant>>>

The lineage’s seal point: the highest epoch sealed, or None if none is.

§Errors

UnknownLineage for a lineage that is not this core’s live one.

Source

pub fn epoch_state( &self, epoch: Epoch<DioringIds<E, <K as StampClock>::Instant>>, ) -> Result<EpochState<DioringIds<E, <K as StampClock>::Instant>>, UnknownLineage<DioringIds<E, <K as StampClock>::Instant>>>

An epoch’s state.

§Errors

UnknownLineage for a lineage that is not this core’s live one.

Source

pub fn close(self) -> Leftovers<DioringIds<E, <K as StampClock>::Instant>, B, C>

End the core, handing back what it still holds: the operations held for their gates, which were never issued, in push order; the unresolved failures; and every lineage with its final high-water mark. What is in flight is the backend’s to run down.

Auto Trait Implementations§

§

impl<E, B, C, K> !RefUnwindSafe for DurableIoCore<E, B, C, K>

§

impl<E, B, C, K> !UnwindSafe for DurableIoCore<E, B, C, K>

§

impl<E, B, C, K> Freeze for DurableIoCore<E, B, C, K>
where Durability<E, IoTargetKey, <K as StampClock>::Instant, K>: Freeze, HashMap<SubmissionToken, InFlight<E, <K as StampClock>::Instant, C>>: Freeze, BTreeMap<u64, HeldOp<E, <K as StampClock>::Instant, B, C>>: Freeze, VecDeque<Entry<DioringIds<E, <K as StampClock>::Instant>, B, C>>: Freeze, Vec<Submission<B>>: Freeze,

§

impl<E, B, C, K> Send for DurableIoCore<E, B, C, K>
where Durability<E, IoTargetKey, <K as StampClock>::Instant, K>: Send, HashMap<SubmissionToken, InFlight<E, <K as StampClock>::Instant, C>>: Send, BTreeMap<u64, HeldOp<E, <K as StampClock>::Instant, B, C>>: Send, VecDeque<Entry<DioringIds<E, <K as StampClock>::Instant>, B, C>>: Send, Vec<Submission<B>>: Send,

§

impl<E, B, C, K> Sync for DurableIoCore<E, B, C, K>
where Durability<E, IoTargetKey, <K as StampClock>::Instant, K>: Sync, HashMap<SubmissionToken, InFlight<E, <K as StampClock>::Instant, C>>: Sync, BTreeMap<u64, HeldOp<E, <K as StampClock>::Instant, B, C>>: Sync, VecDeque<Entry<DioringIds<E, <K as StampClock>::Instant>, B, C>>: Sync, Vec<Submission<B>>: Sync,

§

impl<E, B, C, K> Unpin for DurableIoCore<E, B, C, K>
where Durability<E, IoTargetKey, <K as StampClock>::Instant, K>: Unpin, HashMap<SubmissionToken, InFlight<E, <K as StampClock>::Instant, C>>: Unpin, BTreeMap<u64, HeldOp<E, <K as StampClock>::Instant, B, C>>: Unpin, VecDeque<Entry<DioringIds<E, <K as StampClock>::Instant>, B, C>>: Unpin, Vec<Submission<B>>: Unpin,

§

impl<E, B, C, K> UnsafeUnpin for DurableIoCore<E, B, C, K>
where Durability<E, IoTargetKey, <K as StampClock>::Instant, K>: UnsafeUnpin, HashMap<SubmissionToken, InFlight<E, <K as StampClock>::Instant, C>>: UnsafeUnpin, BTreeMap<u64, HeldOp<E, <K as StampClock>::Instant, B, C>>: UnsafeUnpin, VecDeque<Entry<DioringIds<E, <K as StampClock>::Instant>, B, C>>: UnsafeUnpin, Vec<Submission<B>>: UnsafeUnpin,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.