pub struct Handle<F> { /* private fields */ }Expand description
The failure state and the subscriptions that several databases share: a
failure in one fails every later call and live query on each, with the
host’s failure type F.
Implementations§
Source§impl<F: Clone + Send + Sync + 'static> Handle<F>
impl<F: Clone + Send + Sync + 'static> Handle<F>
Sourcepub fn new(bugs: BugSinkRef, unrecorded: Vec<String>) -> Self
pub fn new(bugs: BugSinkRef, unrecorded: Vec<String>) -> Self
A handle whose bugs outside its calls go to bugs, and whose
databases’ writes record no changes to the tables unrecorded names
for live queries.
Sourcepub fn recording_all(bugs: BugSinkRef) -> Self
pub fn recording_all(bugs: BugSinkRef) -> Self
A test handle for which every table records its changes.
Sourcepub fn unrecorded(&self) -> &Arc<UnrecordedTables> ⓘ
pub fn unrecorded(&self) -> &Arc<UnrecordedTables> ⓘ
The tables whose changes no write records.
Sourcepub fn refuse_upkeep_thread_after(&self, started: Option<usize>)
pub fn refuse_upkeep_thread_after(&self, started: Option<usize>)
Let started upkeep threads start, if given, and refuse the next.
Sourcepub fn upkeep_thread_refused(&self) -> bool
pub fn upkeep_thread_refused(&self) -> bool
Whether the system refuses the upkeep thread starting now.
Sourcepub fn subscribe(&self) -> CommitSubscription
pub fn subscribe(&self) -> CommitSubscription
Observe every commit from now on.
Sourcepub fn subscribe_outside(
&self,
outside: Option<CommitScope>,
) -> CommitSubscription
pub fn subscribe_outside( &self, outside: Option<CommitScope>, ) -> CommitSubscription
Observe every commit except those made within outside. Once the
database has closed, a new subscription reports that it closed, as a
call to the database does, not the failure it may have closed with.
Sourcepub fn changes<R: 'static, E: 'static>(
&self,
reads: ReadSet,
first: bool,
failed: fn(Error<F, R>) -> E,
) -> DatabaseChanges<E>
pub fn changes<R: 'static, E: 'static>( &self, reads: ReadSet, first: bool, failed: fn(Error<F, R>) -> E, ) -> DatabaseChanges<E>
Watch reads from now on; first reports the state now as their
first change.
Sourcepub fn attempt(&self, attempt: CommitScope) -> AttemptCommits
pub fn attempt(&self, attempt: CommitScope) -> AttemptCommits
Keep every commit made from now on outside attempt, until the
attempt names the rows it waits on (watch_attempt).
Sourcepub fn watch_attempt<R: 'static, E: 'static>(
&self,
attempt: AttemptCommits,
reads: ReadSet,
failed: fn(Error<F, R>) -> E,
) -> DatabaseChanges<E>
pub fn watch_attempt<R: 'static, E: 'static>( &self, attempt: AttemptCommits, reads: ReadSet, failed: fn(Error<F, R>) -> E, ) -> DatabaseChanges<E>
Watch reads after attempt: the returned changes report at once a
commit since the attempt began that changed what they read, as
evidence against the wait the attempt ended in.
Sourcepub fn judge(
&self,
changes: Vec<RowChange>,
scope: Option<CommitScope>,
lookups: &mut Lookups<'_>,
) -> Result<Judged>
pub fn judge( &self, changes: Vec<RowChange>, scope: Option<CommitScope>, lookups: &mut Lookups<'_>, ) -> Result<Judged>
Judge a write’s changes, made within scope, for every live query
waiting on known reads that isn’t already marked to run again and
that the changes could affect, with lookups reading the write’s
transaction before it commits (§4).
Sourcepub fn changed_without_write(&self, columns: &[(&str, &str)])
pub fn changed_without_write(&self, columns: &[(&str, &str)])
Tell live queries that each of columns, a (table, column) pair of a
view, changed with no write: each query that read one runs again.
Sourcepub fn commit(&self, judged: Judged, scope: Option<CommitScope>)
pub fn commit(&self, judged: Judged, scope: Option<CommitScope>)
Report a commit made within scope, if any. A query still waiting on
the reads it was judged against takes its verdict. One running keeps
the changes, to judge against its run’s snapshot as it finishes. One
that finished another run since, or wasn’t judged, judges the
changes counting every join’s value as matched: their transaction
has ended, so no lookup can read it. A waiting query the index finds
for none of the changes is affected by none of them.
Sourcepub fn kept_columns(&self) -> BTreeMap<String, BTreeSet<String>>
pub fn kept_columns(&self) -> BTreeMap<String, BTreeSet<String>>
The columns some subscription reads or its scope tests, by table,
all lowercase: a waiting one’s, or a running one’s previous run’s.
Each table such a subscription reads is here, with no column where
it reads none. A write keys the rows it changes in these tables and
keeps those values of them, so it can tell each row’s net change and
test the row against the scopes (net_changes.rs). A change to any
other table needs no values to wake the subscriptions that read it.
Sourcepub fn error<R>(&self) -> Option<Error<F, R>>
pub fn error<R>(&self) -> Option<Error<F, R>>
What every call on the handle fails with: its failure, or
Error::Closed once it closed.
Sourcepub fn has_failed(&self) -> bool
pub fn has_failed(&self) -> bool
Whether the handle failed: a handle its host only closed hasn’t.
Sourcepub fn fail(&self, failure: F)
pub fn fail(&self, failure: F)
Fail every later call and subscription with failure. The handle
keeps the first failure and ignores later ones.
Sourcepub fn fail_engine<R>(&self, failure: EngineFailure<F, R>)where
F: From<EngineFailure<F, R>>,
pub fn fail_engine<R>(&self, failure: EngineFailure<F, R>)where
F: From<EngineFailure<F, R>>,
Fail every later call and subscription with the host’s failure made
from failure, one of sqlive’s own.
Sourcepub fn fail_with_bug(&self, bug: Bug)
pub fn fail_with_bug(&self, bug: Bug)
Fail the handle with bug, a panic in work that may have held its
state or a fault a drop found in it. The handle fails with this bug,
not the one a poisoned lock would name. The bug goes to one
reporter: the handle’s call this thread runs, which returns it as
its own (calling), or the handle’s bug sink, outside such a call or
once the call has a bug of its own already (E15).
Sourcepub fn calling<R>(&self, call: impl FnOnce() -> R) -> (R, Option<Bug>)
pub fn calling<R>(&self, call: impl FnOnce() -> R) -> (R, Option<Bug>)
Run call, one of this handle’s calls, on this thread. Beside its
result comes the bug its own work failed the handle with, if any,
which the call returns as its own (E15). A call that unwinds leaves
that bug to the sink: its panic is the call’s bug then. A call made
inside another on the same handle is part of it, and leaves its bug
to the outer one, which the app hears from.
Sourcepub fn report(&self, bug: &Bug)
pub fn report(&self, bug: &Bug)
Hand bug, which no call returns, to the handle’s bug sink (E15).
Sourcepub fn test_poison(&self)
pub fn test_poison(&self)
Panic while holding the handle’s state, as a bug in judging a commit for live queries would.