pub struct LeasedOwnership { /* private fields */ }Expand description
Clustered Ownership: a Postgres lease per stream (spec §3.3).
Implementations§
Source§impl LeasedOwnership
impl LeasedOwnership
Sourcepub async fn connect(
url: &str,
replica_id: String,
ttl_secs: f64,
) -> Result<Self>
pub async fn connect( url: &str, replica_id: String, ttl_secs: f64, ) -> Result<Self>
Connect, ensure the lease table exists, and identify this replica.
ttl_secs is the lease lifetime; call Self::heartbeat well within it.
Trait Implementations§
Source§impl Ownership for LeasedOwnership
impl Ownership for LeasedOwnership
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,
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,
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,
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.
Auto Trait Implementations§
impl !Freeze for LeasedOwnership
impl !RefUnwindSafe for LeasedOwnership
impl Send for LeasedOwnership
impl Sync for LeasedOwnership
impl Unpin for LeasedOwnership
impl UnsafeUnpin for LeasedOwnership
impl !UnwindSafe for LeasedOwnership
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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