Skip to content

Commit

Permalink
feat: Set timeout to 2 secs
Browse files Browse the repository at this point in the history
  • Loading branch information
Yag000 committed Sep 1, 2023
1 parent f1a3b35 commit 8200d19
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use secrecy::ExposeSecret;
use sqlx::PgPool;
use sqlx::postgres::PgPoolOptions;
use std::net::TcpListener;
use tracing::subscriber::set_global_default;
use tracing_log::LogTracer;
Expand All @@ -16,13 +16,15 @@ async fn main() -> Result<(), std::io::Error> {

// We want to panic if we cannot read the configuration
let configuration = get_configuration().expect("Failed to read configurations");
let connection = PgPool::connect_lazy(
configuration
.database
.get_connnection_string()
.expose_secret(),
)
.expect("Failed to connect to Postgres");
let connection = PgPoolOptions::new()
.acquire_timeout(std::time::Duration::from_secs(2))
.connect_lazy(
configuration
.database
.get_connnection_string()
.expose_secret(),
)
.expect("Failed to connect to Postgres");

// Bind the TCP listener socket address with the configuration port
let address = format!(
Expand Down

0 comments on commit 8200d19

Please sign in to comment.