google_cloud_kms/grpc/apiv1/
conn_pool.rs1use crate::grpc::kms::v1::key_management_service_client::KeyManagementServiceClient;
2use google_cloud_gax::conn::{Channel, Environment};
3use google_cloud_gax::conn::{ConnectionManager as GRPCConnectionManager, ConnectionOptions, Error};
4
5pub const AUDIENCE: &str = "https://cloudkms.googleapis.com/";
6pub const KMS: &str = "cloudkms.googleapis.com";
7pub const SCOPES: [&str; 1] = ["https://www.googleapis.com/auth/cloud-platform"];
8
9#[derive(Debug)]
10pub struct ConnectionManager {
11 inner: GRPCConnectionManager,
12}
13
14impl ConnectionManager {
15 pub async fn new(
16 pool_size: usize,
17 domain: &str,
18 environment: &Environment,
19 conn_options: &ConnectionOptions,
20 ) -> Result<Self, Error> {
21 Ok(ConnectionManager {
22 inner: GRPCConnectionManager::new(pool_size, domain, AUDIENCE, environment, conn_options).await?,
23 })
24 }
25
26 pub fn num(&self) -> usize {
27 self.inner.num()
28 }
29
30 pub fn conn(&self) -> KeyManagementServiceClient<Channel> {
31 KeyManagementServiceClient::new(self.inner.conn()).max_decoding_message_size(i32::MAX as usize)
32 }
33}