MCPcopy Create free account
hub / github.com/Migorithm/rustiful-backend / connection_pool

Function connection_pool

library/src/bootstrap.rs:174–189  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

172static POOL: OnceLock<PgPool> = OnceLock::new();
173
174pub async fn connection_pool() -> &'static PgPool {
175 let url = &env::var("DATABASE_URL").expect("DATABASE_URL must be set");
176 let p = match POOL.get() {
177 None => {
178 let pool = PgPoolOptions::new()
179 .max_connections(30)
180 .connect(url)
181 .await
182 .map_err(|err| ApplicationError::DatabaseConnectionError(Box::new(err)))
183 .unwrap();
184 POOL.get_or_init(|| pool)
185 }
186 Some(pool) => pool,
187 };
188 p
189}
190
191static DEPENDENCY: OnceLock<Dependency> = OnceLock::new();
192

Callers 9

tear_downFunction · 0.85
newMethod · 0.85
test_connectionFunction · 0.85
test_transaction_commitFunction · 0.85
tear_downFunction · 0.85

Calls 1

getMethod · 0.45

Tested by 7

tear_downFunction · 0.68
test_connectionFunction · 0.68
test_transaction_commitFunction · 0.68