pub struct LeaseManager<S: LeaseStorage> { /* private fields */ }Implementations§
Source§impl<S: LeaseStorage + 'static> LeaseManager<S>
impl<S: LeaseStorage + 'static> LeaseManager<S>
pub fn new(storage: Arc<S>, worker_id: String, config: LeaseConfig) -> Self
pub fn worker_id(&self) -> &str
Sourcepub async fn ensure_lease(&self, key: &str) -> Result<()>
pub async fn ensure_lease(&self, key: &str) -> Result<()>
Ensures a lease row exists for this key. Idempotent — safe to call from multiple workers simultaneously.
Sourcepub async fn get_my_lease_keys(&self) -> Result<Vec<String>>
pub async fn get_my_lease_keys(&self) -> Result<Vec<String>>
Returns lease keys currently owned by this worker.
Sourcepub async fn rebalance(&self) -> Result<Vec<String>>
pub async fn rebalance(&self) -> Result<Vec<String>>
Core rebalance algorithm. Tries to reach a fair share of leases for this worker by first claiming unowned leases, then stealing expired ones.
Sourcepub async fn renew_my_leases(&self) -> Result<()>
pub async fn renew_my_leases(&self) -> Result<()>
Renew all leases owned by this worker. Uses concurrent requests to minimize total latency when holding many leases.
pub async fn get_checkpoint(&self, lease_key: &str) -> Result<Option<String>>
pub async fn checkpoint(&self, lease_key: &str, checkpoint: &str) -> Result<()>
Sourcepub fn start_background_tasks(self: Arc<Self>)
pub fn start_background_tasks(self: Arc<Self>)
Spawns background tokio tasks for periodic renewal and rebalancing. Call this once after creating the manager.
Auto Trait Implementations§
impl<S> Freeze for LeaseManager<S>
impl<S> RefUnwindSafe for LeaseManager<S>where
S: RefUnwindSafe,
impl<S> Send for LeaseManager<S>
impl<S> Sync for LeaseManager<S>
impl<S> Unpin for LeaseManager<S>
impl<S> UnsafeUnpin for LeaseManager<S>
impl<S> UnwindSafe for LeaseManager<S>where
S: RefUnwindSafe,
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