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

Function fetch_and_store

gateway/src/proxy/port_policy.rs:211–225  ·  view source on GitHub ↗
(state: &Proxy, instance_id: &str)

Source from the content-addressed store, hash-verified

209}
210
211async 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
227async fn fetch_port_policy(ip: Ipv4Addr, agent_port: u16) -> Result<PortPolicy, FetchError> {
228 let url = format!("http://{ip}:{agent_port}/prpc");

Callers 1

fetch_with_retryFunction · 0.85

Calls 4

fetch_port_policyFunction · 0.85
instance_ipMethod · 0.80
lockMethod · 0.45

Tested by

no test coverage detected