search pool fix

This commit is contained in:
dal 2025-04-16 07:19:24 -06:00
parent 34c2165459
commit bca49aed2a
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
1 changed files with 14 additions and 2 deletions

View File

@ -21,12 +21,24 @@ static REDIS_POOL: OnceCell<RedisPool> = OnceCell::new();
pub async fn init_pools() -> Result<()> {
let diesel_pool = match establish_diesel_connection().await {
Ok(pool) => pool,
Ok(pool) => {
// Warm up Diesel pool by acquiring min_idle connections
for _ in 0..5 {
let _ = pool.get().await;
}
pool
},
Err(e) => return Err(anyhow!("Failed to establish diesel connection: {}", e)),
};
let sqlx_pool = match establish_sqlx_connection().await {
Ok(pool) => pool,
Ok(pool) => {
// Warm up SQLx pool by acquiring min_connections connections
for _ in 0..5 {
let _ = pool.acquire().await;
}
pool
},
Err(e) => return Err(anyhow!("Failed to establish sqlx connection: {}", e)),
};