#grpc #tonic

mobc-tonic

A connection pool for tonic GRPC client

4 releases

0.2.4 Mar 19, 2021
0.2.3 Mar 15, 2021
0.1.0 Mar 14, 2021

#519 in Development tools

Download history 12/week @ 2021-04-05 25/week @ 2021-04-12 4/week @ 2021-04-19 7/week @ 2021-05-03 1/week @ 2021-05-10 8/week @ 2021-05-17 1/week @ 2021-05-24 6/week @ 2021-06-07 2/week @ 2021-06-14 1/week @ 2021-07-05 8/week @ 2021-07-19

57 downloads per month

MIT license

22KB
502 lines

mobc-tonic

A connection pool for tonic GRPC client.

Usage:

First, instantiate the implementation for your client:

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>);

This will generate the connection pool manager for your GRPC client.

Then you could use the generated 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();

License

mobc-tonic is distributed under the terms of MIT.

See LICENSE for details.

Copyright 2021 Tyr Chen

Dependencies

~17MB
~392K SLoC