Skip to content

Commit

Permalink
move pool construction after blocking task
Browse files Browse the repository at this point in the history
  • Loading branch information
aumetra committed Oct 2, 2023
1 parent 142c681 commit 590a373
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions crates/kitsune-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!();
pub async fn connect(conn_str: &str, max_pool_size: usize) -> Result<PgPool> {
LogTracer::init().ok();

let config = AsyncDieselConnectionManager::<AsyncPgConnection>::new(conn_str);
let pool = Pool::builder(config)
.max_size(max_pool_size)
.build()
.unwrap();

tokio::task::spawn_blocking({
let conn_str = conn_str.to_string();

Expand All @@ -61,7 +55,14 @@ pub async fn connect(conn_str: &str, max_pool_size: usize) -> Result<PgPool> {
})
.await??;

let config = AsyncDieselConnectionManager::<AsyncPgConnection>::new(conn_str);
let pool = Pool::builder(config)
.max_size(max_pool_size)
.build()
.unwrap();

let mut conn = pool.get().await?;

kitsune_language::generate_postgres_enum(&mut conn, "language_iso_code").await?;
kitsune_language::generate_regconfig_function(
&mut conn,
Expand Down

0 comments on commit 590a373

Please sign in to comment.