ClickHouse-BB8
ClickHouse-BB8 is a ClickHouse client pool manager compatible with BB8.
It allows you to configure a pool of Rust clients for ClickHouse that can be reused without sharing the underlying http client connection.
Installation
ClickHouse-BB8 is a Rust crate that can be added to your project with Cargo:
Usage
The first step to use the pool manager is to create a ConnectionBuilder.
This builder exposes the same configuration options as the clickhouse::Client,
allowing you to configure URL, database, credentials, and other settings.
use ConnectionBuilder;
let builder = new
.with_url
.with_database
.with_user
.with_password;
Then, create a new ConnectionManager with the builder. This connection manager
implements BB8's ManageConnection trait to keep track of the established connections.
Internally the ConnectionManager executes select 1; to verify that connections are
still valid. If the health check fails, the ConnectionManager marks the connection as
broken and recycles it.
use ConnectionManager;
let manager = new;
Once the ConnectionManager is initialized, use the Pool to create your
connection pool. This Pool is a type alias for bb8::Pool<ConnectionManager>
that allows you to configure the same options as the BB8 builder directly without
having to import the BB8 crate yourself into your project.
use Pool;
let pool = builder
.max_size
.min_idle
.build
.await
.unwrap;
Finally, use your connection pool instance to get clients as necessary in your codebase. For example, you can add your pool as part of the state for your Axum API, and use it to perform queries on your database when your API gets specific requests.
use ;
use ;
use json;
async
async
LICENSE
MIT