Crate bb8_mongodb

source ·
Expand description

A bb8 connection manager for a MongoDB connection pool

** NOTE ** - The bb8 version has been pinned to 0.8.1 for now due to bugs causing tokio timeouts.

§Example

// Setup the MongoDB `ClientOptions`
let mut client_options = ClientOptions::parse("mongodb://somedburi:27017").await?;
client_options.app_name = Some("app".to_string());
client_options.credential = Some(
    Credential::builder()
        .username(Some("dbuser".to_string()))
        .password(Some("dbpass".to_string()))
        .source(Some("dbauthsource".to_string()))
        .build(),
);
client_options.connect_timeout = Some(Duration::from_secs(3));

// Setup the `bb8-mongodb` connection manager
let connection_manager = MongodbConnectionManager::new(client_options, "db");

// Setup the `bb8` connection pool
let pool = Pool::builder().build(connection_manager).await?;

// Get a connection from the pool
let conn = pool.get().await?;

Structs§

Enums§