1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
//! Client Library: Client Functions, Structs, Traits
/// gRPC object traits to provide wrappers for grpc functions
#[tonic::async_trait]
pub trait Client<T>
where
Self: Sized + lib_common::grpc::Client<T> + lib_common::grpc::ClientConnect<T>,
T: Send + Clone,
{
/// The type expected for ReadyRequest structs.
type ReadyRequest;
/// The type expected for ReadyResponse structs.
type ReadyResponse;
/// Returns a [`tonic::Response`] containing a [`ReadyResponse`](Self::ReadyResponse)
/// Takes an [`ReadyRequest`](Self::ReadyRequest).
///
/// # Errors
///
/// Returns [`tonic::Status`] with [`tonic::Code::Unknown`] if the server is not ready.
///
/// # Examples
/// ```
/// use lib_common::grpc::get_endpoint_from_env;
/// use svc_assets_client_grpc::prelude::*;
///
/// async fn example () -> Result<(), Box<dyn std::error::Error>> {
/// let (host, port) = get_endpoint_from_env("SERVER_HOSTNAME", "SERVER_PORT_GRPC");
/// let client = AssetsClient::new_client(&host, port, "assets");
/// let response = client
/// .is_ready(assets::ReadyRequest {})
/// .await?;
/// println!("RESPONSE={:?}", response.into_inner());
/// Ok(())
/// }
/// ```
async fn is_ready(
&self,
request: Self::ReadyRequest,
) -> Result<tonic::Response<Self::ReadyResponse>, tonic::Status>;
}