MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / init

Method init

examples/rocket_okapi_example/api/src/pool.rs:24–37  ·  view source on GitHub ↗
(figment: &Figment)

Source from the content-addressed store, hash-verified

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 if let Some(idle_timeout) = config.idle_timeout {
32 options.idle_timeout(Duration::from_secs(idle_timeout));
33 }
34 let conn = sea_orm::Database::connect(options).await?;
35
36 Ok(SeaOrmPool { conn })
37 }
38
39 async fn get(&self) -> Result<Self::Connection, Self::Error> {
40 Ok(self.conn.clone())

Callers

nothing calls this directly

Calls 5

unwrapMethod · 0.80
connect_timeoutMethod · 0.80
min_connectionsMethod · 0.80
max_connectionsMethod · 0.80
idle_timeoutMethod · 0.80

Tested by

no test coverage detected