Skip to content

Commit

Permalink
chore: improve sql startup
Browse files Browse the repository at this point in the history
  • Loading branch information
jhandguy committed Apr 15, 2023
1 parent b4064a5 commit e489ea1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
7 changes: 1 addition & 6 deletions sql/src/mysql.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::str::FromStr;
use std::time::Duration;

use anyhow::Result;
use sqlx::mysql::{MySqlConnectOptions, MySqlPoolOptions};
Expand All @@ -17,11 +16,7 @@ pub async fn connect(
let options = MySqlConnectOptions::from_str(&url)?
.disable_statement_logging()
.clone();
let pool = MySqlPoolOptions::new()
.acquire_timeout(Duration::from_secs(3))
.max_connections(5)
.connect_with(options)
.await?;
let pool = MySqlPoolOptions::new().connect_with(options).await?;

Ok(pool)
}
Expand Down
7 changes: 1 addition & 6 deletions sql/src/postgres.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::str::FromStr;
use std::time::Duration;

use anyhow::Result;
use sqlx::postgres::{PgConnectOptions, PgPoolOptions};
Expand All @@ -17,11 +16,7 @@ pub async fn connect(
let options = PgConnectOptions::from_str(&url)?
.disable_statement_logging()
.clone();
let pool = PgPoolOptions::new()
.acquire_timeout(Duration::from_secs(3))
.max_connections(5)
.connect_with(options)
.await?;
let pool = PgPoolOptions::new().connect_with(options).await?;

Ok(pool)
}
Expand Down
4 changes: 2 additions & 2 deletions terraform/environments/redis/modules.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module "redis" {
}

module "sql_postgres" {
depends_on = [module.metrics, module.prometheus, module.postgresql, module.redis]
depends_on = [module.metrics, module.loki, module.postgresql, module.redis]
source = "../../modules/sql"

feature = "postgres"
Expand All @@ -65,7 +65,7 @@ module "sql_postgres" {
}

module "sql_mysql" {
depends_on = [module.metrics, module.prometheus, module.mysql, module.redis]
depends_on = [module.metrics, module.loki, module.mysql, module.redis]
source = "../../modules/sql"

feature = "mysql"
Expand Down

0 comments on commit e489ea1

Please sign in to comment.