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
impl RetryWaits
Sourcepub fn connection_changed(&self)
pub fn connection_changed(&self)
The storage connection changed: waits for storage are woken.
Sourcepub fn connection_version(&self) -> u64
pub fn connection_version(&self) -> u64
The credential/connection version a connection failure waits to change.
Source§impl RetryWaits
impl RetryWaits
Sourcepub fn report_network(&self)
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.
Sourcepub fn network_reports(&self) -> NetworkReportWatch
pub fn network_reports(&self) -> NetworkReportWatch
Changes with every report, for an owner that waits on its own timers.
Sourcepub async fn end_reported_waits(
&self,
owner: NetworkOwner,
) -> Result<bool, SyncError>
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
impl RetryWaits
Sourcepub async fn retry_requested(self: &Arc<Self>) -> Result<RetryAnswer, DbError>
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.
Sourcepub async fn show_worker_failure(&self, error: SyncError) -> Result<(), DbError>
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.
Sourcepub async fn sync_started(self: &Arc<Self>) -> Result<(), SyncError>
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).
Sourcepub async fn sync_stopped(self: &Arc<Self>) -> Result<(), DbError>
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.
Sourcepub async fn sync_halted(self: &Arc<Self>, bug: Bug) -> Result<(), DbError>
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.
Sourcepub async fn sync_panicked(self: &Arc<Self>, bug: Bug) -> Result<(), DbError>
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).
Sourcepub async fn begin_pass(
self: &Arc<Self>,
) -> Result<Option<PassRequests>, DbError>
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.
Sourcepub async fn holds(
self: &Arc<Self>,
failure: Option<&PassFailure>,
) -> Result<(), DbError>
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.
Sourcepub async fn answer_held(
self: &Arc<Self>,
failure: Option<&PassFailure>,
) -> Result<(), DbError>
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.
Sourcepub async fn return_requests(
self: &Arc<Self>,
taken: PassRequests,
) -> Result<(), DbError>
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
impl RetryWaits
Sourcepub async fn open(
database: StoreDatabase,
clock: ClockRef,
) -> Result<Self, DbError>
pub async fn open( database: StoreDatabase, clock: ClockRef, ) -> Result<Self, DbError>
Arm every persisted wait with the restart rule (§6.7).
Sourcepub fn in_memory(clock: ClockRef) -> Self
pub fn in_memory(clock: ClockRef) -> Self
A read-only handle cannot persist: its cooldowns hold only its own requests.
Sourcepub fn halted(&self) -> Option<Bug>
pub fn halted(&self) -> Option<Bug>
The bug that halted sync for the rest of this store’s session, if
one has (sync_halted).
Sourcepub fn halt(&self) -> impl Future<Output = Bug> + Send + 'static
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.
Sourcepub fn due(&self, subject: RetrySubject, persisted: Option<&RetryWait>) -> bool
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).
Sourcepub fn next_wake(
&self,
matching: impl Fn(&RetrySubject) -> bool,
) -> Option<Pin<Box<dyn Future<Output = ()> + Send>>>
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.
Trait Implementations§
Source§impl Cooldown for RetryWaits
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,
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.
Auto Trait Implementations§
impl !Freeze for RetryWaits
impl !RefUnwindSafe for RetryWaits
impl !UnwindSafe for RetryWaits
impl Send for RetryWaits
impl Sync for RetryWaits
impl Unpin for RetryWaits
impl UnsafeUnpin for RetryWaits
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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