Skip to main content

WriteLeaseProvider

Trait WriteLeaseProvider 

Source
pub trait WriteLeaseProvider: Send + Sync {
    // Required methods
    fn acquire<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<LeaseGuard>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn heartbeat<'life0, 'life1, 'async_trait>(
        &'life0 self,
        guard: &'life1 LeaseGuard,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn release<'life0, 'async_trait>(
        &'life0 self,
        guard: LeaseGuard,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait for custom write lease providers.

Implement this trait to provide distributed write coordination (e.g., via DynamoDB, etcd, Redis, ZooKeeper).

Required Methods§

Source

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

Attempt to acquire the write lease. Returns Err if the lease is held by another writer.

Source

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

Renew the lease before it expires.

Source

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

Release the lease. Called on graceful shutdown.

Implementors§