Skip to main content

Ownership

Trait Ownership 

Source
pub trait Ownership: Send + Sync {
    // Required methods
    fn try_acquire<'life0, 'life1, 'async_trait>(
        &'life0 self,
        stream_key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Option<Lease>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn renew<'life0, 'life1, 'async_trait>(
        &'life0 self,
        lease: &'life1 Lease,
    ) -> 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,
        stream_key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn owns(&self, stream_key: &str) -> bool;
}
Expand description

Single-writer ownership of streams.

Required Methods§

Source

fn try_acquire<'life0, 'life1, 'async_trait>( &'life0 self, stream_key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Option<Lease>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Claim stream_key if it is free, expired, or already held by THIS process (idempotent — re-acquiring your own live lease returns it and does not change its epoch). Returns None if another live replica owns it.

Source

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

Extend a held lease. Err if the lease was lost (stolen/expired) — which is how a replica learns it is no longer the owner.

Source

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

Release a held stream so a peer may claim it immediately (graceful hand-off), rather than waiting for TTL expiry.

Source

fn owns(&self, stream_key: &str) -> bool

Whether this process currently owns stream_key. Cheap/in-memory: it is consulted on the poll loop’s hot path.

Implementors§