Persist the current in-memory `InstanceInfo` snapshot to WaveKV.
(&self, instance_id: &str)
| 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 |
no test coverage detected