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

fix: increasing Postgres connection pool size #309

Merged
merged 1 commit into from
Mar 13, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ pub mod state;
pub mod stores;
pub mod supabase;

const PG_CONNECTION_POOL_SIZE: u32 = 30;

pub async fn bootstap(mut shutdown: broadcast::Receiver<()>, config: Config) -> error::Result<()> {
// Check config is valid and then throw the error if its not
config.is_valid()?;
Expand All @@ -76,7 +78,7 @@ pub async fn bootstap(mut shutdown: broadcast::Receiver<()>, config: Config) ->
.clone();

let store = PgPoolOptions::new()
.max_connections(5)
.max_connections(PG_CONNECTION_POOL_SIZE)
.connect_with(pg_options)
.await?;

Expand All @@ -95,7 +97,7 @@ pub async fn bootstap(mut shutdown: broadcast::Receiver<()>, config: Config) ->
.clone();

let tenant_database = PgPoolOptions::new()
.max_connections(5)
.max_connections(PG_CONNECTION_POOL_SIZE)
.connect_with(tenant_pg_options)
.await?;

Expand Down
6 changes: 4 additions & 2 deletions tests/context/stores.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use {
tracing::log::LevelFilter,
};

const PG_CONNECTION_POOL_SIZE: u32 = 30;

pub async fn open_pg_connections(
database_uri: &str,
tenant_database_uri: &str,
Expand All @@ -18,7 +20,7 @@ pub async fn open_pg_connections(
.clone();

let pool = PgPoolOptions::new()
.max_connections(5)
.max_connections(PG_CONNECTION_POOL_SIZE)
.connect_with(pg_options)
.await
.expect("failed to connect to postgres");
Expand All @@ -35,7 +37,7 @@ pub async fn open_pg_connections(
.clone();

let tenant_pool = PgPoolOptions::new()
.max_connections(5)
.max_connections(PG_CONNECTION_POOL_SIZE)
.connect_with(tenant_pg_options)
.await
.expect("failed to connect to postgres");
Expand Down
Loading