config: simplify runtime environment model

This commit is contained in:
a.tolmachev
2026-04-11 12:40:00 +03:00
parent 9b6ce337e6
commit 51cf7691be
14 changed files with 127 additions and 66 deletions
+9 -1
View File
@@ -10,7 +10,7 @@ use serde::{Serialize, de::DeserializeOwned};
use serde_json::Value;
use sqlx::{
PgPool, Postgres, Row, Transaction,
postgres::{PgPoolOptions, PgRow},
postgres::{PgConnectOptions, PgPoolOptions, PgRow},
types::Json,
};
@@ -46,6 +46,14 @@ impl PostgresRegistry {
Self::connect_in_schema(database_url, None).await
}
pub async fn connect_with_options(
connect_options: PgConnectOptions,
) -> Result<Self, RegistryError> {
let pool = PgPoolOptions::new().connect_with(connect_options).await?;
migrations::apply_postgres(&pool).await?;
Ok(Self { pool })
}
pub fn pool(&self) -> &PgPool {
&self.pool
}