Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a bit more documentation around the reexported pool types #179

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/pooled_connection/bb8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
//! # async fn run_test() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
//! # use schema::users::dsl::*;
//! # let config = get_config();
//! let pool = Pool::builder().build(config).await?;
//! # #[cfg(feature = "postgres")]
//! let pool: Pool<AsyncPgConnection> = Pool::builder().build(config).await?;
//! # #[cfg(not(feature = "postgres"))]
//! # let pool = Pool::builder().build(config).await?;
//! let mut conn = pool.get().await?;
//! # conn.begin_test_transaction();
//! # create_tables(&mut conn).await;
Expand All @@ -53,6 +56,9 @@ use bb8::ManageConnection;
use diesel::query_builder::QueryFragment;

/// Type alias for using [`bb8::Pool`] with [`diesel-async`]
///
/// This is **not** equal to [`bb8::Pool`]. It already uses the correct
/// connection manager and expects only the connection type as generic argument
pub type Pool<C> = bb8::Pool<AsyncDieselConnectionManager<C>>;
/// Type alias for using [`bb8::PooledConnection`] with [`diesel-async`]
pub type PooledConnection<'a, C> = bb8::PooledConnection<'a, AsyncDieselConnectionManager<C>>;
Expand Down
8 changes: 7 additions & 1 deletion src/pooled_connection/deadpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
//! # async fn run_test() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
//! # use schema::users::dsl::*;
//! # let config = get_config();
//! let pool = Pool::builder(config).build()?;
//! # #[cfg(feature = "postgres")]
//! let pool: Pool<AsyncPgConnection> = Pool::builder(config).build()?;
//! # #[cfg(not(feature = "postgres"))]
//! # let pool = Pool::builder(config).build()?;
//! let mut conn = pool.get().await?;
//! # conn.begin_test_transaction();
//! # create_tables(&mut conn).await;
Expand All @@ -51,6 +54,9 @@ use deadpool::managed::Manager;
use diesel::query_builder::QueryFragment;

/// Type alias for using [`deadpool::managed::Pool`] with [`diesel-async`]
///
/// This is **not** equal to [`deadpool::managed::Pool`]. It already uses the correct
/// connection manager and expects only the connection type as generic argument
pub type Pool<C> = deadpool::managed::Pool<AsyncDieselConnectionManager<C>>;
/// Type alias for using [`deadpool::managed::PoolBuilder`] with [`diesel-async`]
pub type PoolBuilder<C> = deadpool::managed::PoolBuilder<AsyncDieselConnectionManager<C>>;
Expand Down
9 changes: 8 additions & 1 deletion src/pooled_connection/mobc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
//! # async fn run_test() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
//! # use schema::users::dsl::*;
//! # let config = get_config();
//! let pool = Pool::new(config);
//! # #[cfg(feature = "postgres")]
//! let pool: Pool<AsyncPgConnection> = Pool::new(config);
//! # #[cfg(not(feature = "postgres"))]
//! # let pool = Pool::new(config);
//! let mut conn = pool.get().await?;
//! # conn.begin_test_transaction();
//! # create_tables(&mut conn).await;
Expand All @@ -51,6 +54,10 @@ use diesel::query_builder::QueryFragment;
use mobc::Manager;

/// Type alias for using [`mobc::Pool`] with [`diesel-async`]
///
///
/// This is **not** equal to [`mobc::Pool`]. It already uses the correct
/// connection manager and expects only the connection type as generic argument
pub type Pool<C> = mobc::Pool<AsyncDieselConnectionManager<C>>;

/// Type alias for using [`mobc::Connection`] with [`diesel-async`]
Expand Down
Loading