Skip to content

Commit

Permalink
adding additional pool options
Browse files Browse the repository at this point in the history
  • Loading branch information
jstuczyn committed Nov 22, 2024
1 parent b7f5a29 commit fa462b2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions nym-api/src/support/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,20 @@ impl NymApiStorage {
pub async fn init<P: AsRef<Path>>(database_path: P) -> Result<Self, NymApiStorageError> {
// TODO: we can inject here more stuff based on our nym-api global config
// struct. Maybe different pool size or timeout intervals?
let opts = sqlx::sqlite::SqliteConnectOptions::new()
let connect_opts = sqlx::sqlite::SqliteConnectOptions::new()
.filename(database_path)
.create_if_missing(true)
.log_statements(LevelFilter::Trace)
.log_slow_statements(LevelFilter::Warn, Duration::from_millis(250));

// TODO: do we want auto_vacuum ?

let connection_pool = match sqlx::SqlitePool::connect_with(opts).await {
let pool_opts = sqlx::sqlite::SqlitePoolOptions::new()
.min_connections(5)
.max_connections(25)
.acquire_timeout(Duration::from_secs(60));

let connection_pool = match pool_opts.connect_with(connect_opts).await {
Ok(db) => db,
Err(err) => {
error!("Failed to connect to SQLx database: {err}");
Expand Down

0 comments on commit fa462b2

Please sign in to comment.