MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / try_acquire_cert_lock

Method try_acquire_cert_lock

gateway/src/kv/mod.rs:950–972  ·  view source on GitHub ↗

Try to acquire certificate renew lock Returns true if lock acquired, false if already locked by another node

(&self, domain: &str, lock_timeout_secs: u64)

Source from the content-addressed store, hash-verified

948 /// Try to acquire certificate renew lock
949 /// Returns true if lock acquired, false if already locked by another node
950 pub fn try_acquire_cert_lock(&self, domain: &str, lock_timeout_secs: u64) -> bool {
951 let now = std::time::SystemTime::now()
952 .duration_since(std::time::UNIX_EPOCH)
953 .unwrap_or_default()
954 .as_secs();
955
956 if let Some(existing) = self.get_cert_lock(domain) {
957 // Check if lock is still valid (not expired)
958 if now < existing.started_at + lock_timeout_secs {
959 return false;
960 }
961 }
962
963 // Acquire the lock
964 let lock = CertRenewLock {
965 started_at: now,
966 started_by: self.my_node_id,
967 };
968 self.persistent
969 .write()
970 .put_encoded(keys::cert_lock(domain), &lock)
971 .is_ok()
972 }
973
974 /// Release certificate renew lock
975 pub fn release_cert_lock(&self, domain: &str) -> Result<()> {

Callers 2

try_renewMethod · 0.80
request_new_certMethod · 0.80

Calls 4

cert_lockFunction · 0.85
get_cert_lockMethod · 0.80
put_encodedMethod · 0.80
writeMethod · 0.80

Tested by

no test coverage detected