1
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use diesel::pg::PgConnection;
|
||||
use diesel::r2d2::{ConnectionManager, Pool};
|
||||
|
||||
pub type PgPool = Pool<ConnectionManager<PgConnection>>;
|
||||
|
||||
pub fn init_pool(database_url: &str) -> anyhow::Result<PgPool> {
|
||||
let manager = ConnectionManager::<PgConnection>::new(database_url);
|
||||
let pool = Pool::builder()
|
||||
.max_size(16)
|
||||
.connection_timeout(Duration::from_secs(10))
|
||||
.build(manager)?;
|
||||
Ok(pool)
|
||||
}
|
||||
Reference in New Issue
Block a user