pub struct Session { /* private fields */ }Expand description
Owner of one mutation line, its records, and its tracked documents.
Implementations§
Source§impl Session
impl Session
Sourcepub fn new(storage: impl Storage + Send + 'static) -> Session
pub fn new(storage: impl Storage + Send + 'static) -> Session
Open a Session over one storage backend. The first error a Storage call returns, other than a
StorageError::Request from a read, fails the Session.
Sourcepub fn with_clock(
storage: impl Storage + Send + 'static,
now: impl Fn() -> u64 + Send + Sync + 'static,
) -> Session
pub fn with_clock( storage: impl Storage + Send + 'static, now: impl Fn() -> u64 + Send + Sync + 'static, ) -> Session
now is the wall clock (milliseconds) stamped on task lifecycle times.
Sourcepub fn commit<T>(
&self,
change: impl FnOnce(&mut Tx<'_>) -> Result<T, SessionError>,
) -> Result<T, SessionError>
pub fn commit<T>( &self, change: impl FnOnce(&mut Tx<'_>) -> Result<T, SessionError>, ) -> Result<T, SessionError>
Run one atomic transaction on the mutation line. Its changes publish only after Storage acknowledges them.
Sourcepub fn commit_with<T>(
&self,
scope: TxScope,
change: impl FnOnce(&mut Tx<'_>) -> Result<T, SessionError>,
) -> Result<T, SessionError>
pub fn commit_with<T>( &self, scope: TxScope, change: impl FnOnce(&mut Tx<'_>) -> Result<T, SessionError>, ) -> Result<T, SessionError>
commit with defaults: the conversation of Tx::create_task and the task stamped on appended entries.
Sourcepub fn snapshot(
&self,
doc: &Doc,
owner: Owner,
) -> Result<Option<Arc<Value>>, SessionError>
pub fn snapshot( &self, doc: &Doc, owner: Owner, ) -> Result<Option<Arc<Value>>, SessionError>
The committed value of a document; never creates one.
Sourcepub fn fail(&self, error: SessionError)
pub fn fail(&self, error: SessionError)
Fail the Session with error, the first failure wins: admission ends, close listeners run, every watch ends,
and Storage closes. Must not be called on the mutation line (from a commit callback or listener).
Sourcepub fn subscribe_commits(
&self,
listener: impl Fn(&CommitPublication) + Send + Sync + 'static,
) -> Result<Subscription, SessionError>
pub fn subscribe_commits( &self, listener: impl Fn(&CommitPublication) + Send + Sync + 'static, ) -> Result<Subscription, SessionError>
Observe complete commits synchronously after adoption, on the committing thread. The listener must not block or call Session APIs.
Sourcepub fn subscribe_close(
&self,
listener: impl Fn() + Send + Sync + 'static,
) -> Result<Subscription, SessionError>
pub fn subscribe_close( &self, listener: impl Fn() + Send + Sync + 'static, ) -> Result<Subscription, SessionError>
Observe close synchronously when it begins, also when a failed Storage call closes the Session.
Sourcepub fn close(&self) -> Result<(), SessionError>
pub fn close(&self) -> Result<(), SessionError>
Seal admission, settle commits already admitted, then close Storage. Later calls wait for the first.
Sourcepub fn wait_closed(&self) -> SessionEnd
pub fn wait_closed(&self) -> SessionEnd
Wait until the Session has closed, Storage included: after close(), or after the first failed Storage call.