MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / lease_coordinator

Method lease_coordinator

crates/openshell-server/src/compute/mod.rs:878–913  ·  view source on GitHub ↗
(self: Arc<Self>, mut shutdown_rx: watch::Receiver<bool>)

Source from the content-addressed store, hash-verified

876 }
877
878 async fn lease_coordinator(self: Arc<Self>, mut shutdown_rx: watch::Receiver<bool>) {
879 use lease::{LEASE_ACQUIRE_INTERVAL, LEASE_TTL, ReconcilerLease};
880
881 let lease = ReconcilerLease::new(self.store.clone(), self.replica_id.clone(), LEASE_TTL);
882 info!(replica = %lease.replica_id(), "reconciler lease coordinator started");
883
884 loop {
885 if *shutdown_rx.borrow() {
886 break;
887 }
888
889 match lease.acquire_or_steal().await {
890 Ok(guard) => {
891 info!(replica = %lease.replica_id(), "acquired reconciler lease");
892 self.run_as_holder(&lease, guard, &mut shutdown_rx).await;
893 }
894 Err(e) => {
895 debug!(
896 replica = %lease.replica_id(),
897 error = %e,
898 "reconciler lease acquisition attempt failed"
899 );
900 tokio::select! {
901 () = tokio::time::sleep(LEASE_ACQUIRE_INTERVAL) => {}
902 _ = shutdown_rx.changed() => {
903 if *shutdown_rx.borrow() {
904 break;
905 }
906 }
907 }
908 }
909 }
910 }
911
912 info!(replica = %lease.replica_id(), "reconciler lease coordinator stopped");
913 }
914
915 async fn run_as_holder(
916 self: &Arc<Self>,

Callers 1

spawn_watchersMethod · 0.80

Calls 2

acquire_or_stealMethod · 0.80
run_as_holderMethod · 0.80

Tested by

no test coverage detected