pub struct PostgresLock { /* private fields */ }Available on crate feature
postgres only.Expand description
Postgres-backed distributed lock.
Trait Implementations§
Source§impl DistributedLock for PostgresLock
impl DistributedLock for PostgresLock
Source§fn try_acquire<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 AdvisoryKey,
_ttl: Duration,
) -> Pin<Box<dyn Future<Output = PersistenceResult<Option<LockGuard>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn try_acquire<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 AdvisoryKey,
_ttl: Duration,
) -> Pin<Box<dyn Future<Output = PersistenceResult<Option<LockGuard>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Try once to acquire
key with the given ttl. Returns
Ok(Some(guard)) on success, Ok(None) when the key is
currently held by another holder, and Err(_) for backend
failure.Source§fn acquire<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 AdvisoryKey,
ttl: Duration,
deadline: Duration,
) -> Pin<Box<dyn Future<Output = PersistenceResult<LockGuard>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn acquire<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 AdvisoryKey,
ttl: Duration,
deadline: Duration,
) -> Pin<Box<dyn Future<Output = PersistenceResult<LockGuard>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Block until the lock is acquired or
deadline elapses.
Implementors poll with backoff between attempts.Source§fn extend<'life0, 'life1, 'async_trait>(
&'life0 self,
_guard: &'life1 LockGuard,
_ttl: Duration,
) -> Pin<Box<dyn Future<Output = PersistenceResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn extend<'life0, 'life1, 'async_trait>(
&'life0 self,
_guard: &'life1 LockGuard,
_ttl: Duration,
) -> Pin<Box<dyn Future<Output = PersistenceResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Extend the holder’s TTL. Returns
Ok(false) when the lock has
already been released or expired (the guard’s token no longer
matches the stored value).Source§fn release<'life0, 'async_trait>(
&'life0 self,
guard: LockGuard,
) -> Pin<Box<dyn Future<Output = PersistenceResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn release<'life0, 'async_trait>(
&'life0 self,
guard: LockGuard,
) -> Pin<Box<dyn Future<Output = PersistenceResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Release the lock. Consumes the guard. The implementation is a
no-op when the token already mismatches (lock expired by TTL
before the caller got here).
Auto Trait Implementations§
impl Freeze for PostgresLock
impl !RefUnwindSafe for PostgresLock
impl Send for PostgresLock
impl Sync for PostgresLock
impl Unpin for PostgresLock
impl UnsafeUnpin for PostgresLock
impl !UnwindSafe for PostgresLock
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> 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