Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(db): add variable pool size #45

Merged
merged 1 commit into from Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/config.rs
Expand Up @@ -38,6 +38,7 @@ pub struct Database {
pub host: String,
pub port: u16,
pub dbname: String,
pub pool_size: Option<usize>,
}

#[derive(Clone, serde::Deserialize, Debug)]
Expand Down
9 changes: 8 additions & 1 deletion src/storage.rs
Expand Up @@ -43,7 +43,14 @@ impl Storage {
);
let config =
pooled_connection::AsyncDieselConnectionManager::<AsyncPgConnection>::new(database_url);
let pool = Pool::builder(config)
let pool = Pool::builder(config);

let pool = match database.pool_size {
Some(value) => pool.max_size(value),
None => pool,
};

let pool = pool
.build()
.change_context(error::StorageError::DBPoolError)?;
Ok(Self {
Expand Down