4 个版本

0.2.4 2021 年 3 月 19 日
0.2.3 2021 年 3 月 15 日
0.1.0 2021 年 3 月 14 日

开发工具 中排名 1464

MIT 许可证

23KB
502

mobc-tonic

tonic GRPC 客户端的连接池。

用法

首先,实例化您客户端的实现

use mobc_tonic::{
    instantiate_client_pool, ClientConfig, Error, InterceptorFn, Manager, MobcTonicError, Pool,
};
use tonic::transport::{Certificate, Channel, ClientTlsConfig, Identity};

use gen::greeter_client::GreeterClient;

instantiate_client_pool!(GreeterClient<Channel>);

这将为您生成 GRPC 客户端的连接池管理器。

然后您可以使用生成的 ClientPool

let client_config: ClientConfig =
    toml::from_str(include_str!("fixtures/client_with_cert.toml")).unwrap();

let pool = ClientPool::new(client_config);
let mut client = pool.get().await.unwrap();
let reply = client
    .say_hello(HelloRequest {
        name: "Tyr".to_owned(),
    })
    .await
    .unwrap()
    .into_inner();

许可证

mobc-tonic 根据 MIT 许可证分发。

有关详细信息,请参阅 LICENSE

版权所有 2021 Tyr Chen

依赖项

~16MB
~376K SLoC