pub struct Lease { /* private fields */ }Expand description
Represents a held distributed lease & background task to continuously try to extend it until dropped.
On drop asynchronously releases the underlying lock.
Implementations§
Source§impl Lease
impl Lease
Sourcepub async fn release(self) -> Result<()>
pub async fn release(self) -> Result<()>
Releases the lease returning Ok(()) after successful deletion.
Note: The local guard is unlocked first before deleting the lease. This avoids other concurrent acquires in the same process being unfairly advantaged in acquiring subsequent leases and potentially causing other processes to be starved.
If you await this method then immediately acquire a lease, e.g. inside a loop, you are acquiring with an unfair advantage vs other process attempts. This may lead to other process being starved of leases.
Sourcepub fn is_healthy(&self) -> bool
pub fn is_healthy(&self) -> bool
Returns true if the lease periodic extension task is still running.
If lease extension fails, e.g. due to lost contact with the db, this
will return false.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Lease
impl !RefUnwindSafe for Lease
impl Send for Lease
impl Sync for Lease
impl Unpin for Lease
impl !UnwindSafe for Lease
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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>
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