Skip to main content

Module pool

Module pool 

Source
Expand description

Process-wide gRPC channel pool.

The sole public function is pool::get_channel. Consumers do not typically call it directly — the constructors generated by GrpcClient and GrpcNoAuthClient call it internally. Process-wide gRPC channel pool.

Channels are keyed by endpoint string and created lazily on first use. Subsequent calls with the same endpoint string reuse the cached channel. The pool is backed by a RwLock<HashMap<String, Channel>> and is safe to use from multiple threads.

The sole public function is [get_channel]. Consumers do not call it directly — the from_endpoint_with_provider and from_endpoint constructors generated by #[derive(GrpcClient)] / #[derive(GrpcNoAuthClient)] call it internally.

Keepalive timing is controlled by two environment variables read at channel creation time:

VariableDefault
RUST_GRPC_LIB_KEEP_ALIVE_INTERVAL_SECS30
RUST_GRPC_LIB_KEEP_ALIVE_TIMEOUT_SECS10

Functions§

get_channel
Return a [Channel] for endpoint, reusing a cached one if it exists.