pub struct LeaseLifecycle { /* private fields */ }Expand description
Drives the serverless writer lease for one database key.
Owns the WriterLease snapshot, the LeaseStore it talks to,
and the side-effect channels (WriteGate, AuditLogger,
MarkDraining). All transitions go through methods on this
struct so the gate/audit pair stays consistent.
Implementations§
Source§impl LeaseLifecycle
impl LeaseLifecycle
pub fn new( store: Arc<LeaseStore>, write_gate: Arc<WriteGate>, audit_log: Arc<AuditLogger>, mark_draining: MarkDraining, holder_id: String, database_key: String, ttl_ms: u64, ) -> Self
pub fn holder_id(&self) -> &str
pub fn database_key(&self) -> &str
pub fn ttl_ms(&self) -> u64
pub fn current_lease(&self) -> Option<WriterLease>
Sourcepub fn try_acquire(&self) -> RedDBResult<()>
pub fn try_acquire(&self) -> RedDBResult<()>
Acquire the writer lease and flip the gate to Held. Audit
line records the outcome (ok / err) either way.
Sourcepub fn refresh(&self) -> RedDBResult<()>
pub fn refresh(&self) -> RedDBResult<()>
Refresh the held lease. On success, updates the in-memory
snapshot and returns Ok(()). On any backend error, flips
the gate to NotHeld, audits lease/lost, asks the runtime
to drain, and returns Err.
The refresh thread should treat Err as terminal and exit
— re-acquiring after a loss could race a freshly promoted
writer.
Sourcepub fn release(&self) -> RedDBResult<()>
pub fn release(&self) -> RedDBResult<()>
Release the held lease and flip the gate to NotHeld. Best-
effort: a backend failure is logged but does not propagate
— shutdown should not block on a remote release.
Auto Trait Implementations§
impl !Freeze for LeaseLifecycle
impl !RefUnwindSafe for LeaseLifecycle
impl Send for LeaseLifecycle
impl Sync for LeaseLifecycle
impl Unpin for LeaseLifecycle
impl UnsafeUnpin for LeaseLifecycle
impl !UnwindSafe for LeaseLifecycle
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request