use no_data_component_client::NoDataComponentClient;
use tonic::transport::Channel;
include!("gen/nodata.v1.rs");
pub struct GrpcComponentClient {
host_name: String,
}
impl GrpcComponentClient {
pub async fn new(host_name: impl Into<String>) -> anyhow::Result<Self> {
Ok(Self {
host_name: host_name.into(),
})
}
pub async fn ping(&self) -> anyhow::Result<Option<()>> {
self.create_client().await?.ping(PingRequest {}).await?;
Ok(Some(()))
}
pub(crate) async fn create_client(&self) -> anyhow::Result<NoDataComponentClient<Channel>> {
Ok(NoDataComponentClient::connect(self.host_name.clone()).await?)
}
}