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

Method persist_instance_record

gateway/src/main_service.rs:1020–1036  ·  view source on GitHub ↗

Persist the current in-memory `InstanceInfo` snapshot to WaveKV.

(&self, instance_id: &str)

Source from the content-addressed store, hash-verified

1018
1019 /// Persist the current in-memory `InstanceInfo` snapshot to WaveKV.
1020 fn persist_instance_record(&self, instance_id: &str) {
1021 let Some(info) = self.state.instances.get(instance_id) else {
1022 return;
1023 };
1024 let data = InstanceData {
1025 app_id: info.app_id.clone(),
1026 ip: info.ip,
1027 public_key: info.public_key.clone(),
1028 reg_time: encode_ts(info.reg_time),
1029 port_policy: info.port_policy.clone(),
1030 port_policy_hash: info.port_policy_hash.clone(),
1031 admin_port_policy: info.admin_port_policy.clone(),
1032 };
1033 if let Err(err) = self.kv_store.sync_instance(instance_id, &data) {
1034 error!("failed to sync instance {instance_id} to KvStore: {err:?}");
1035 }
1036 }
1037
1038 fn add_instance(&mut self, info: InstanceInfo) {
1039 // Sync to KvStore

Callers 3

set_admin_port_policyMethod · 0.80

Calls 4

encode_tsFunction · 0.85
cloneMethod · 0.80
sync_instanceMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected