pub trait LockBackend: Send + Sync {
// Required methods
fn try_acquire<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<(u64, Instant)>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn try_renew<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
token: u64,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<Instant>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn release<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
token: u64,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn name(&self) -> &'static str { ... }
}Expand description
Authoritative storage and arbitration for distributed locks.
The returned Instant on try_acquire / try_renew is the local
lease deadline (when this node should consider the lease expired absent a
renewal). It is intentionally not serialized across the wire — remote
backends translate a TTL into a local deadline on receipt.
Required Methods§
Sourcefn try_acquire<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<(u64, Instant)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn try_acquire<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<(u64, Instant)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Attempt to acquire key for ttl. On success returns the fencing token
(strictly monotonic per key) and the local lease deadline.
Sourcefn try_renew<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
token: u64,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<Instant>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn try_renew<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
token: u64,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<Instant>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Renew a lease previously acquired with token, extending it by ttl.
Returns the new local lease deadline.
Sourcefn release<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
token: u64,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn release<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
token: u64,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Release a lease. A no-op if token is already stale (someone else owns
the key), so releasing an expired guard is harmless.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".