Skip to content

Commit

Permalink
chore: increase database connection timeout (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
sagojez authored Oct 23, 2024
1 parent 6085c97 commit 4719277
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions integrationos-api/src/domain/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ pub struct ConnectionsConfig {
default = "integrationos-database"
)]
pub database_connection_docker_image: String,
#[envconfig(from = "DATABASE_CONNECTION_PROBE_TIMEOUT_SECS", default = "10")]
pub database_connection_probe_timeout_secs: u64,
#[envconfig(from = "K8S_MODE", default = "logger")]
pub k8s_mode: K8sMode,
#[envconfig(from = "OTLP_ENDPOINT")]
Expand Down
9 changes: 6 additions & 3 deletions integrationos-api/src/logic/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,11 @@ async fn test_connection(
})
.transpose()?;

// Wait 3 seconds to allow the resource to be created
tokio::time::sleep(Duration::from_secs(3)).await;
// Wait up to 10 seconds to allow the resource to be created
tokio::time::sleep(Duration::from_secs(
state.config.database_connection_probe_timeout_secs,
))
.await;

let res = state
.extractor_caller
Expand Down Expand Up @@ -290,7 +293,7 @@ pub async fn create_connection(
}

Err(ApplicationError::bad_request(
"Invalid connection credentials: {:?}",
&format!("Invalid connection credentials: {:?}", e),
None,
))
}
Expand Down

0 comments on commit 4719277

Please sign in to comment.