pub trait Client<T>where
    Self: Sized + Client<T> + ClientConnect<T>,
    T: Send + Clone,
{ type ReadyRequest; type ReadyResponse; type PricingRequests; type PricingResponse; 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
; fn get_pricing<'life0, 'async_trait>(
        &'life0 self,
        request: Self::PricingRequests
    ) -> Pin<Box<dyn Future<Output = Result<Response<Self::PricingResponse>, 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§

The type expected for ReadyRequest structs.

The type expected for ReadyResponse structs.

The type expected for PricingRequests structs.

The type expected for PricingResponse structs.

Required Methods§

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_pricing_client_grpc::client::{ReadyRequest, RpcServiceClient};
use svc_pricing_client_grpc::{Client, GrpcClient};
use svc_pricing_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, "pricing");
    let response = connection
        .is_ready(ReadyRequest {})
        .await?;
    println!("RESPONSE={:?}", response.into_inner());
    Ok(())
}

Returns a tonic::Response containing a PricingResponse Takes an PricingRequests.

Errors

Returns tonic::Status with Code::Internal if no pricing could be determined.

Examples
use lib_common::grpc::get_endpoint_from_env;
use svc_pricing_client_grpc::client::{PricingRequests, PricingRequest, RpcServiceClient};
use svc_pricing_client_grpc::{Client, GrpcClient};
use svc_pricing_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, "pricing");
    let query = PricingRequests {
        requests: vec![PricingRequest {
            service_type: 0,
            weight_kg: 100.0,
            distance_km: 100.0,
        }]
    };
    let response = connection.get_pricing(query).await?;
    println!("RESPONSE={:?}", response.into_inner());
    Ok(())
}

Implementors§