MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / new

Method new

chirpstack/src/integration/postgresql/mod.rs:201–227  ·  view source on GitHub ↗
(conf: &Config)

Source from the content-addressed store, hash-verified

199
200impl Integration {
201 pub async fn new(conf: &Config) -> Result<Integration> {
202 info!("Initializing PostgreSQL integration");
203
204 let mut config = ManagerConfig::default();
205 config.custom_setup = Box::new(pg_establish_connection);
206
207 let mgr =
208 AsyncDieselConnectionManager::<AsyncPgConnection>::new_with_config(&conf.dsn, config);
209 let pg_pool = DeadpoolPool::builder(mgr)
210 .max_size(conf.max_open_connections as usize)
211 .build()?;
212
213 let c = pg_pool.get().await?;
214 let mut c_wrapped: AsyncConnectionWrapper<AsyncPgPoolConnection> =
215 AsyncConnectionWrapper::from(c);
216
217 info!("Applying schema migrations");
218 tokio::task::spawn_blocking(move || -> Result<()> {
219 c_wrapped
220 .run_pending_migrations(MIGRATIONS)
221 .map_err(|e| anyhow!("{}", e))?;
222 Ok(())
223 })
224 .await??;
225
226 Ok(Integration { pg_pool })
227 }
228}
229
230// Source:

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected