pub struct LockGuard { /* private fields */ }Expand description
A held distributed lock.
The lock is released when the guard is dropped (background, best-effort) or
via LockGuard::unlock (awaited). While held, a supervised watchdog renews
the lease automatically; if renewal fails the guard becomes poisoned and
LockGuard::fencing_token / LockGuard::extend start returning errors.
Implementations§
Source§impl LockGuard
impl LockGuard
Sourcepub fn fencing_token(&self) -> Result<u64>
pub fn fencing_token(&self) -> Result<u64>
The strictly-monotonic fencing token for this lock.
§Errors
Returns Error::LeaseExpired if the guard has been poisoned by a
failed renewal — the token must not be used to authorise writes.
Sourcepub fn acquired_at(&self) -> Stamp
pub fn acquired_at(&self) -> Stamp
The causal stamp recorded when the lock was acquired.
Backed by the ash-time Hybrid Logical Clock when that feature is
enabled; otherwise a local monotonic counter. Useful for ordering lock
events in logs/audit trails across nodes.
Sourcepub async fn extend(&self, new_ttl: Duration) -> Result<()>
pub async fn extend(&self, new_ttl: Duration) -> Result<()>
Manually extend the lease by new_ttl from now. On success the
watchdog adopts new_ttl for all subsequent renewals, so the extension
is not undone at the next renewal tick.
§Errors
Fails if the guard is poisoned, or if the backend rejects the renewal (stale token / expired lease).