async fn serves_host(self, host: &str) -> Result<(Instance, ClientId), Error> {
        let addr = SocketAddr::new(self.ip.clone(), crate::CONFIG.internal_network_port);
        let url = format!("http://{}", addr.to_string());
        let client = reqwest::Client::new();
        let response = client
            .get(url)
            .timeout(std::time::Duration::from_secs(2))
            .query(&HostQuery {
                host: host.to_string(),
            })
            .send()
            .await
            .map_err(|e| {
                tracing::error!(error=?e, "failed to send a host query");
                e
            })?;
        let status = response.status();
        let result: HostQueryResponse = response.json().await?;

        let found_client = result
            .client_id
            .as_ref()
            .map(|c| c.to_string())
            .unwrap_or_default();
        tracing::debug!(status=%status, found=%found_client, "got net svc response");

        match (status, result.client_id) {
            (StatusCode::OK, Some(client_id)) => Ok((self, client_id)),
            _ => Err(Error::DoesNotServeHost),
        }
    }
/// query the instance and see if it runs our host
query the instance and see if it runs our host
query the instance and see if it runs our host
async fn serves_host(self, host: &str) -> Result<(Instance, ClientId), Error> {
        let addr = SocketAddr::new(self.ip.clone(), crate::CONFIG.internal_network_port);
        let url = format!("http://{}", addr.to_string());
        let client = reqwest::Client::new();
        let response = client
            .get(url)
            .timeout(std::time::Duration::from_secs(2))
            .query(&HostQuery {
                host: host.to_string(),
            })
            .send()
            .await
            .map_err(|e| {
                tracing::error!(error=?e, "failed to send a host query");
                e
            })?;
        let status = response.status();
        let result: HostQueryResponse = response.json().await?;
        let found_client = result
            .client_id
            .as_ref()
            .map(|c| c.to_string())
            .unwrap_or_default();
        tracing::debug!(status=%status, found=%found_client, "got net svc response");
        match (status, result.client_id) {
            (StatusCode::OK, Some(client_id)) => Ok((self, client_id)),
            _ => Err(Error::DoesNotServeHost),
        }
    }
async fn serves_host ( self , host : & str ) -> Result < ( Instance , ClientId ) , Error > { let addr = SocketAddr :: new ( self . ip . clone ( ) , crate :: CONFIG . internal_network_port ) ; let url = format ! ( " " addr to_string ( ) ) ; let client = reqwest :: Client :: new ( ) ; let response = client . get ( url ) . timeout ( std :: time :: Duration :: from_secs ( 2 ) ) . query ( & HostQuery { host : host . to_string ( ) , } ) . send ( ) . await . map_err ( | e | { tracing :: error ! ( error e " " ) ; e } ) ? ; let status = response . status ( ) ; let result : HostQueryResponse = response . json ( ) . await ? ; let found_client = result . client_id . as_ref ( ) . map ( | c | c . to_string ( ) ) . unwrap_or_default ( ) ; tracing :: debug ! ( status status found found_client " " ) ; match ( status , result . client_id ) { ( StatusCode :: OK , Some ( client_id ) ) => Ok ( ( self , client_id ) ) , _ => Err ( Error :: DoesNotServeHost ) , } }
query the instance and see if it runs our host
query the instance and see if it runs our host
self
host
&str