Trait svc_telemetry_client_grpc::service::Client
source · pub trait Client<T>where
Self: Sized + Client<T> + ClientConnect<T>,
T: Send + Clone,{
type ReadyRequest;
type ReadyResponse;
fn is_ready<'life0, 'async_trait>(
&'life0 self,
request: Self::ReadyRequest
) -> Pin<Box<dyn Future<Output = Result<Response<Self::ReadyResponse>, Status>> + Send + 'async_trait>>
where
Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
gRPC object traits to provide wrappers for grpc functions
Required Associated Types§
sourcetype ReadyRequest
type ReadyRequest
The type expected for ReadyRequest structs.
sourcetype ReadyResponse
type ReadyResponse
The type expected for ReadyResponse structs.
Required Methods§
sourcefn is_ready<'life0, 'async_trait>(
&'life0 self,
request: Self::ReadyRequest
) -> Pin<Box<dyn Future<Output = Result<Response<Self::ReadyResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn is_ready<'life0, 'async_trait>(
&'life0 self,
request: Self::ReadyRequest
) -> Pin<Box<dyn Future<Output = Result<Response<Self::ReadyResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns a tonic::Response
containing a ReadyResponse
Takes an ReadyRequest
.
Errors
Returns tonic::Status
with Code::Unknown
if
the server is not ready.
Examples
use lib_common::grpc::get_endpoint_from_env;
use svc_telemetry_client_grpc::client::{ReadyRequest, RpcServiceClient};
use svc_telemetry_client_grpc::{Client, GrpcClient};
use svc_telemetry_client_grpc::service::Client as ServiceClient;
use tonic::transport::Channel;
async fn example () -> Result<(), Box<dyn std::error::Error>> {
let (host, port) = get_endpoint_from_env("SERVER_HOSTNAME", "SERVER_PORT_GRPC");
let connection = GrpcClient::<RpcServiceClient<Channel>>::new_client(&host, port, "telemetry");
let response = connection
.is_ready(ReadyRequest {})
.await?;
println!("RESPONSE={:?}", response.into_inner());
Ok(())
}