use anyhow::Result; use sqlx::{PgPool, postgres::PgPoolOptions}; use tracing::{debug, trace}; use crate::config::DatabaseOptions; pub(super) async fn connect(opts: &DatabaseOptions) -> Result { trace!(host = ?opts.url.host(), "connecting to database"); let pg = PgPoolOptions::new() .max_connections(opts.pool_size) .connect(opts.url.as_str()) .await?; debug!(host = ?opts.url.host(), "connected to database"); Ok(pg) }