(state: &Proxy, instance_id: &str)
| 209 | } |
| 210 | |
| 211 | async fn fetch_and_store(state: &Proxy, instance_id: &str) -> Result<(), FetchError> { |
| 212 | let (ip, agent_port) = { |
| 213 | let guard = state.lock(); |
| 214 | let ip = guard |
| 215 | .instance_ip(instance_id) |
| 216 | // Instance was recycled — never coming back under this id. |
| 217 | .ok_or_else(|| FetchError::Permanent(anyhow::anyhow!("unknown instance")))?; |
| 218 | (ip, guard.config.proxy.agent_port) |
| 219 | }; |
| 220 | let policy = fetch_port_policy(ip, agent_port).await?; |
| 221 | state |
| 222 | .lock() |
| 223 | .update_instance_port_policy(instance_id, policy); |
| 224 | Ok(()) |
| 225 | } |
| 226 | |
| 227 | async fn fetch_port_policy(ip: Ipv4Addr, agent_port: u16) -> Result<PortPolicy, FetchError> { |
| 228 | let url = format!("http://{ip}:{agent_port}/prpc"); |
no test coverage detected