Skip to main content

RetryWaits

Struct RetryWaits 

Source
pub struct RetryWaits { /* private fields */ }
Expand description

One installation’s retry schedule. Construct when the store opens and inject the same owner into operations, file transfers, the sync loop and every provider connection.

Implementations§

Source§

impl RetryWaits

Source

pub fn connection_changed(&self)

The storage connection changed: waits for storage are woken.

Source

pub fn connection_version(&self) -> u64

The credential/connection version a connection failure waits to change.

Source§

impl RetryWaits

Source

pub fn report_network(&self)

The device reached a usable network: one appeared, or it moved to another (§6.7). Each owner acts on the report when it next plans; reports before then coalesce.

Source

pub fn network_reports(&self) -> NetworkReportWatch

Changes with every report, for an owner that waits on its own timers.

Source

pub async fn end_reported_waits( &self, owner: NetworkOwner, ) -> Result<bool, SyncError>

End the waits the reports since owner last acted end (§6.7): its waits for the network, or every ordinary wait it retries after a retry report. Each ended wait keeps its failure count, so the next failure continues the backoff, and is saved ended, so no reopen arms it again (IO ended_reopens_due). The provider cooldown holds, and a network report leaves a wait after a provider’s answer and one held because saving it failed. Returns whether a report arrived, so the owner also runs the work it asks for. If reading or saving fails, every wait holds, the owner reports the error, and the reports stay unacted on, so the owner’s next plan acts on them again.

Source§

impl RetryWaits

Source

pub async fn retry_requested(self: &Arc<Self>) -> Result<RetryAnswer, DbError>

The person asked to retry everything now (§6.7): each owner ends every ordinary wait it retries when it next plans, as for a network report, answered or not, and the provider cooldown holds. Stopped, held or cooling down, as the row says, answers at once; otherwise the first pass that begins after the connection’s owner acted on the request answers it. A closed store answers NotSyncing: no pass follows.

Source

pub async fn show_worker_failure(&self, error: SyncError) -> Result<(), DbError>

The upload worker’s own work failed with error, which is no bug and which no caller hears: write it as how the last pass ended, so the sync state shows it (§19.1). A failed write has failed the handle.

Source

pub async fn sync_started(self: &Arc<Self>) -> Result<(), SyncError>

A started connection will plan: requests wait for its passes, and the failure its owner last found still holds them. Once a worker’s panic has halted sync (sync_halted), it fails with that bug as SyncError::WorkerFailed until the store reopens (E15).

Source

pub async fn sync_stopped(self: &Arc<Self>) -> Result<(), DbError>

Sync stopped, or no connection will plan: no pass follows a waiting request, so each is answered NotSyncing. A pass already running answers the requests it took.

Source

pub async fn sync_halted(self: &Arc<Self>, bug: Bug) -> Result<(), DbError>

The upload worker, which serves the whole store, panicked with bug, which the sink heard: sync halts for the rest of this store’s session, as the connection owner’s own panic halts it (E15). The last pass shows the bug with nothing moving, sync stops, each waiting request hears it as SyncError::WorkerFailed, the connection’s owner ends on it, and every start fails with it until the store reopens.

Source

pub async fn sync_panicked(self: &Arc<Self>, bug: Bug) -> Result<(), DbError>

The connection’s owner panicked with bug, which the sink heard, so no pass follows a waiting request: sync stops, and each request, those the panicking pass took among them, is answered Failed with SyncError::WorkerFailed carrying the bug (E15).

Source

pub async fn begin_pass( self: &Arc<Self>, ) -> Result<Option<PassRequests>, DbError>

A pass begins, if the row lets one: sync is started, and neither a failure nor a cooldown holds it. It takes every waiting request the connection’s owner has acted on (IO pass_answers_acted_on). None when the row holds the pass, and the owner plans again.

Source

pub async fn holds( self: &Arc<Self>, failure: Option<&PassFailure>, ) -> Result<(), DbError>

The connection’s owner found what holds every pass: a failure only new credentials, an update or a reset can clear, or none. It says so as it opens and after each pass, before writing the status a failed pass leaves, so the effect never trails that status; each time it plans, answer_held says so too.

Source

pub async fn answer_held( self: &Arc<Self>, failure: Option<&PassFailure>, ) -> Result<(), DbError>

The owner plans: it records what holds every pass, as holds does, and answers the requests it has acted on now if no pass will run for them (IO held_answers). A failure only new credentials, an update or a reset can clear answers Failed; otherwise a live provider cooldown answers CoolingDown, and anything else that holds the pass leaves them for it. The answer is the effect’s.

Source

pub async fn return_requests( self: &Arc<Self>, taken: PassRequests, ) -> Result<(), DbError>

The connection’s first attempt connected: its requests wait for the loop’s first pass, or are answered NotSyncing if sync stopped meanwhile.

Source§

impl RetryWaits

Source

pub async fn open( database: StoreDatabase, clock: ClockRef, ) -> Result<Self, DbError>

Arm every persisted wait with the restart rule (§6.7).

Source

pub fn in_memory(clock: ClockRef) -> Self

A read-only handle cannot persist: its cooldowns hold only its own requests.

Source

pub fn halted(&self) -> Option<Bug>

The bug that halted sync for the rest of this store’s session, if one has (sync_halted).

Source

pub fn halt(&self) -> impl Future<Output = Bug> + Send + 'static

Resolves with the bug that halts sync, once one has: the connection’s owner then ends as on its own panic.

Source

pub fn rearmed(&self) -> RearmWatch

Changes whenever a failed attempt arms a new wait.

Source

pub fn due(&self, subject: RetrySubject, persisted: Option<&RetryWait>) -> bool

Whether automatic work on the subject may start now, given its persisted wait. No subject is due while the provider cooldown lasts. An absent row means the work advanced or the app retried it, unless this session holds the subject because persisting its wait failed. An operation’s wait can also end by evidence (operation_evidence.rs).

Source

pub fn next_wake( &self, matching: impl Fn(&RetrySubject) -> bool, ) -> Option<Pin<Box<dyn Future<Output = ()> + Send>>>

Resolves when the earliest armed subject matching is due: its timer and any live provider cooldown have both fired. A wait that ended after its owner last evaluated it wakes at once; one the owner has evaluated since wakes nothing until new evidence or a new wait. None when nothing it covers waits on a timer.

Source

pub fn cooldown_wake(&self) -> Option<Pin<Box<dyn Future<Output = ()> + Send>>>

Resolves when the live provider cooldown ends.

Trait Implementations§

Source§

impl Cooldown for RetryWaits

Source§

fn record<'life0, 'async_trait>( &'life0 self, wait: Duration, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Arm first, so no consumer in this session retries, then persist it with what it makes a retry do, in one transaction (retry_answer.rs). A cooldown never shortens one already live.

Source§

fn remaining(&self) -> Option<Duration>

The live cooldown’s remaining wait, measured monotonically.

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more