Skip to main content

DistributedLock

Trait DistributedLock 

Source
pub trait DistributedLock: Send + Sync {
    // Required methods
    fn acquire<'life0, 'life1, 'async_trait>(
        &'life0 self,
        resource_key: &'life1 str,
        options: LockOptions,
    ) -> Pin<Box<dyn Future<Output = Result<Guard, DistributedError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn release<'life0, 'async_trait>(
        &'life0 self,
        guard: Guard,
    ) -> Pin<Box<dyn Future<Output = Result<(), DistributedError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn extend<'life0, 'life1, 'async_trait>(
        &'life0 self,
        guard: &'life1 Guard,
        additional_ttl_ms: u64,
    ) -> Pin<Box<dyn Future<Output = Result<(), DistributedError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

An abstraction for acquiring and releasing distributed locks.

Required Methods§

Source

fn acquire<'life0, 'life1, 'async_trait>( &'life0 self, resource_key: &'life1 str, options: LockOptions, ) -> Pin<Box<dyn Future<Output = Result<Guard, DistributedError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Attempt to acquire a distributed lock on a resource.

Source

fn release<'life0, 'async_trait>( &'life0 self, guard: Guard, ) -> Pin<Box<dyn Future<Output = Result<(), DistributedError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Release the acquired lock.

Source

fn extend<'life0, 'life1, 'async_trait>( &'life0 self, guard: &'life1 Guard, additional_ttl_ms: u64, ) -> Pin<Box<dyn Future<Output = Result<(), DistributedError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Extend the TTL of the currently held lock.

Implementors§