Skip to content

Commit

Permalink
Apply new configs for mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
rmn-boiko committed Jan 8, 2025
1 parent 1a2f8c9 commit 387a398
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/utils/database-common/src/plugins/mysql_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0.

use std::time::Duration;

use dill::*;
use secrecy::ExposeSecret;
use sqlx::mysql::MySqlConnectOptions;
use sqlx::MySqlPool;
use sqlx::pool::PoolOptions;
use sqlx::{MySql, MySqlPool};

use crate::*;

Expand Down Expand Up @@ -58,7 +61,20 @@ impl MySqlPlugin {
.password(db_credentials.password.expose_secret());
}

MySqlPool::connect_lazy_with(mysql_options)
let mysql_pool: PoolOptions<MySql> = PoolOptions::new()
.max_lifetime(
db_connection_settings
.max_lifetime_secs
.map(Duration::from_secs),
)
.max_connections(db_connection_settings.max_connections.unwrap_or(10))
.acquire_timeout(
db_connection_settings
.acquire_timeout_secs
.map_or(Duration::from_secs(30), Duration::from_secs),
);

mysql_pool.connect_lazy_with(mysql_options)
}
}

Expand Down

0 comments on commit 387a398

Please sign in to comment.