(figment: &Figment)
| 22 | type Connection = sea_orm::DatabaseConnection; |
| 23 | |
| 24 | async fn init(figment: &Figment) -> Result<Self, Self::Error> { |
| 25 | let config = figment.extract::<Config>().unwrap(); |
| 26 | let mut options: ConnectOptions = config.url.into(); |
| 27 | options |
| 28 | .max_connections(config.max_connections as u32) |
| 29 | .min_connections(config.min_connections.unwrap_or_default()) |
| 30 | .connect_timeout(Duration::from_secs(config.connect_timeout)) |
| 31 | .sqlx_logging(config.sqlx_logging); |
| 32 | if let Some(idle_timeout) = config.idle_timeout { |
| 33 | options.idle_timeout(Duration::from_secs(idle_timeout)); |
| 34 | } |
| 35 | let conn = sea_orm::Database::connect(options).await?; |
| 36 | |
| 37 | Ok(SeaOrmPool { conn }) |
| 38 | } |
| 39 | |
| 40 | async fn get(&self) -> Result<Self::Connection, Self::Error> { |
| 41 | Ok(self.conn.clone()) |
no test coverage detected