pub struct WorkerLease { /* private fields */ }Expand description
Strict single-owner execution guard for a lease. Verify ownership and expiry before executing.
Implementations§
Source§impl WorkerLease
impl WorkerLease
Sourcepub fn from_record(record: LeaseRecord) -> Self
pub fn from_record(record: LeaseRecord) -> Self
Build a worker lease from a repository lease record (e.g. from get_lease_for_attempt).
Sourcepub fn record(&self) -> &LeaseRecord
pub fn record(&self) -> &LeaseRecord
Lease record for heartbeat or persistence.
pub fn lease_id(&self) -> &str
pub fn attempt_id(&self) -> &str
pub fn worker_id(&self) -> &str
Sourcepub fn is_expired(&self, now: DateTime<Utc>) -> bool
pub fn is_expired(&self, now: DateTime<Utc>) -> bool
Returns true if the lease has passed its expiry time (no heartbeat grace here).
Sourcepub fn verify_owner(&self, worker_id: &str) -> Result<(), KernelError>
pub fn verify_owner(&self, worker_id: &str) -> Result<(), KernelError>
Enforce single-owner: returns Ok(()) only if worker_id matches the lease owner.
Sourcepub fn check_execution_allowed(
&self,
worker_id: &str,
now: DateTime<Utc>,
) -> Result<(), KernelError>
pub fn check_execution_allowed( &self, worker_id: &str, now: DateTime<Utc>, ) -> Result<(), KernelError>
Returns Ok(()) if the given worker owns the lease and it is not yet expired.
Trait Implementations§
Source§impl Clone for WorkerLease
impl Clone for WorkerLease
Source§fn clone(&self) -> WorkerLease
fn clone(&self) -> WorkerLease
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for WorkerLease
impl RefUnwindSafe for WorkerLease
impl Send for WorkerLease
impl Sync for WorkerLease
impl Unpin for WorkerLease
impl UnsafeUnpin for WorkerLease
impl UnwindSafe for WorkerLease
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