(&mut self, id: &str)
| 1232 | } |
| 1233 | |
| 1234 | fn remove_instance(&mut self, id: &str) -> Result<()> { |
| 1235 | let info = self |
| 1236 | .state |
| 1237 | .instances |
| 1238 | .remove(id) |
| 1239 | .context("instance not found")?; |
| 1240 | |
| 1241 | // Sync deletion to KvStore |
| 1242 | if let Err(err) = self.kv_store.sync_delete_instance(id) { |
| 1243 | error!("Failed to sync instance deletion to KvStore: {err:?}"); |
| 1244 | } |
| 1245 | |
| 1246 | self.state.allocated_addresses.remove(&info.ip); |
| 1247 | if let Some(app_instances) = self.state.apps.get_mut(&info.app_id) { |
| 1248 | app_instances.remove(id); |
| 1249 | if app_instances.is_empty() { |
| 1250 | self.state.apps.remove(&info.app_id); |
| 1251 | } |
| 1252 | } |
| 1253 | Ok(()) |
| 1254 | } |
| 1255 | |
| 1256 | fn recycle(&mut self) -> Result<()> { |
| 1257 | // Refresh state: sync local handshakes to KvStore, update local last_seen from global |
no test coverage detected