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
11#[cfg(feature="client")]
12pub async fn connect_to_client() -> Result<AgentClient<Channel>, Error> {
13 let channel = Channel::from_static(AGENT_IP)
16 .connect()
17 .await?;
18 let client = AgentClient::new(channel);
19 Ok(client)
20}
21#[cfg(feature="client")]
22pub async fn connect_to_server_reflection() -> Result<ServerReflectionClient<Channel>, Error> {
23 let channel = Channel::from_static(AGENT_IP)
25 .connect()
26 .await?;
27 let client = ServerReflectionClient::new(channel);
28 Ok(client)
29}