agent_api/
client.rs

1use anyhow::Error;
2use std::result::Result::Ok;
3use tonic::{transport::Channel};
4use tonic_reflection::pb::v1::{
5    server_reflection_client::ServerReflectionClient,
6};
7use crate::agent::agent_client::AgentClient;
8
9const AGENT_IP : &str = "http://127.0.0.1:9090";
10
11pub async fn connect_to_client() -> Result<AgentClient<Channel>, Error> {
12    //this methods force a HTTP/2 connection from a static string
13    //FIXME: this will require an update to ensure a protected connection
14    let channel = Channel::from_static(AGENT_IP)
15        .connect()
16        .await?;
17    let client = AgentClient::new(channel);
18    Ok(client)
19}
20
21pub async fn connect_to_server_reflection() -> Result<ServerReflectionClient<Channel>, Error> {
22    //this methods force a HTTP/2 connection from a static string
23    let channel = Channel::from_static(AGENT_IP)
24        .connect()
25        .await?;
26    let client = ServerReflectionClient::new(channel);
27    Ok(client)
28}