/// Create new connection pool.
///
/// If `use_mock_grpc` is set only mock gRPC clients are created.
Create new connection pool.
If `use_mock_grpc` is set only mock gRPC clients are created.
Create new connection pool . If ` use_mock_grpc ` is set only mock gRPC clients are created .
pub async fn new(use_mock_grpc: bool, wb_factory: Arc<WriteBufferConfigFactory>) -> Self {
        // Note: this function is async even though it does not contain any `.await` calls because `LoadingCache::new`
        // requires tokio to be running and even if documented people will forget about this.
        let grpc_clients = if use_mock_grpc {
            LoadingCache::new(|_connection_string: String| async move {
                use crate::grpc_client::MockClient;
                Ok(Arc::new(MockClient::default()) as Arc<dyn GrpcClient>)
            })
        } else {
            LoadingCache::new(|connection_string: String| async move {
                use crate::grpc_client::RealClient;
                use influxdb_iox_client::connection::Builder;
                let connection = Builder::default()
                    .build(&connection_string)
                    .await
                    .map_err(|e| Arc::new(e) as ConnectionError)?;
                Ok(Arc::new(RealClient::new(connection)) as Arc<dyn GrpcClient>)
            })
        };
        let write_buffer_producers = LoadingCache::new(move |key: KeyWriteBufferProducer| {
            let wb_factory = Arc::clone(&wb_factory);
            async move {
                wb_factory
                    .new_config_write(&key.0, &key.1)
                    .await
                    .map_err(|e| Arc::new(EWrapper(e)) as ConnectionError)
            }
        });
        Self {
            grpc_clients,
            write_buffer_producers,
        }
    }
pub async fn new ( use_mock_grpc : bool , wb_factory : Arc < WriteBufferConfigFactory > ) -> Self { // Note: this function is async even though it does not contain any `.await` calls because `LoadingCache::new` // requires tokio to be running and even if documented people will forget about this. let grpc_clients = if use_mock_grpc { LoadingCache :: new ( | _connection_string : String | async move { use crate :: grpc_client :: MockClient ; Ok ( Arc :: new ( MockClient :: default ( ) ) as Arc < dyn GrpcClient > ) } ) } else { LoadingCache :: new ( | connection_string : String | async move { use crate :: grpc_client :: RealClient ; use influxdb_iox_client :: connection :: Builder ; let connection = Builder :: default ( ) . build ( & connection_string ) . await . map_err ( | e | Arc :: new ( e ) as ConnectionError ) ? ; Ok ( Arc :: new ( RealClient :: new ( connection ) ) as Arc < dyn GrpcClient > ) } ) } ; let write_buffer_producers = LoadingCache :: new ( move | key : KeyWriteBufferProducer | { let wb_factory = Arc :: clone ( & wb_factory ) ; async move { wb_factory . new_config_write ( & key . 0 , & key . 1 ) . await . map_err ( | e | Arc :: new ( EWrapper ( e ) ) as ConnectionError ) } } ) ; Self { grpc_clients , write_buffer_producers , } }
Create new connection pool.
Create new connection pool .
use_mock_grpc
bool
wb_factory
Arc<WriteBufferConfigFactory>