Skip to content

Commit

Permalink
rsc: Determine pool connection timeout from config (#1611)
Browse files Browse the repository at this point in the history
  • Loading branch information
V-FEXrt authored Jul 30, 2024
1 parent 17bbbcb commit 8687031
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rust/rsc/src/bin/rsc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct RSCConfig {
// The address the that server should bind to
pub server_address: String,
// The amount of time a query should wait for a connection before timing out in seconds
pub connection_pool_timeout: u32,
pub connection_pool_timeout: u64,
// The blob store that new blobs should be written into
pub active_store: String,
// The directory that server logs should be written to. If None logs are written to stdout
Expand Down
7 changes: 6 additions & 1 deletion rust/rsc/src/bin/rsc/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,13 @@ fn create_router(
async fn connect_to_database(
config: &config::RSCConfig,
) -> Result<DatabaseConnection, Box<dyn std::error::Error>> {
let timeout = config.connection_pool_timeout;
let mut opt = ConnectOptions::new(&config.database_url);
opt.sqlx_logging_level(tracing::log::LevelFilter::Debug);
opt.sqlx_logging_level(tracing::log::LevelFilter::Debug)
.acquire_timeout(std::time::Duration::from_secs(timeout));

tracing::info!(%timeout, "Max seconds to wait for connection from pool");

let connection = Database::connect(opt).await?;
let pending_migrations = Migrator::get_pending_migrations(&connection).await?;
if pending_migrations.len() != 0 {
Expand Down

0 comments on commit 8687031

Please sign in to comment.