pub struct CrossProcessStoreLock<S>{ /* private fields */ }
Expand description
A store-based lock for a Store
.
See the doc-comment of this module for more information.
Implementations§
source§impl<S> CrossProcessStoreLock<S>
impl<S> CrossProcessStoreLock<S>
sourcepub fn new(
store: S,
lock_key: String,
lock_holder: String,
) -> CrossProcessStoreLock<S>
pub fn new( store: S, lock_key: String, lock_holder: String, ) -> CrossProcessStoreLock<S>
Create a new store-based lock implemented as a value in the store.
§Parameters
lock_key
: key in the key-value store to store the lock’s state.lock_holder
: identify the lock’s holder with this given value.
sourcepub async fn try_lock_once(
&self,
) -> Result<Option<CrossProcessStoreLockGuard>, LockStoreError>
pub async fn try_lock_once( &self, ) -> Result<Option<CrossProcessStoreLockGuard>, LockStoreError>
Try to lock once, returns whether the lock was obtained or not.
sourcepub async fn spin_lock(
&self,
max_backoff: Option<u32>,
) -> Result<CrossProcessStoreLockGuard, LockStoreError>
pub async fn spin_lock( &self, max_backoff: Option<u32>, ) -> Result<CrossProcessStoreLockGuard, LockStoreError>
Attempt to take the lock, with exponential backoff if the lock has already been taken before.
The max_backoff
parameter is the maximum time (in milliseconds) that
should be waited for, between two attempts. When that time is
reached a second time, the lock will stop attempting to get the lock
and will return a timeout error upon locking. If not provided,
will wait for MAX_BACKOFF_MS
.
sourcepub fn lock_holder(&self) -> &str
pub fn lock_holder(&self) -> &str
Returns the value in the database that represents the holder’s identifier.
Trait Implementations§
source§impl<S> Clone for CrossProcessStoreLock<S>
impl<S> Clone for CrossProcessStoreLock<S>
source§fn clone(&self) -> CrossProcessStoreLock<S>
fn clone(&self) -> CrossProcessStoreLock<S>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<S> Freeze for CrossProcessStoreLock<S>where
S: Freeze,
impl<S> !RefUnwindSafe for CrossProcessStoreLock<S>
impl<S> Send for CrossProcessStoreLock<S>
impl<S> Sync for CrossProcessStoreLock<S>where
S: Sync,
impl<S> Unpin for CrossProcessStoreLock<S>where
S: Unpin,
impl<S> !UnwindSafe for CrossProcessStoreLock<S>
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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
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 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>
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