|
|
|
|
@ -2,6 +2,7 @@ use std::sync::Arc;
|
|
|
|
|
use deadpool_postgres::{Pool, Config, Runtime}; |
|
|
|
|
use tokio::sync::OnceCell; |
|
|
|
|
use tokio_postgres::NoTls; |
|
|
|
|
use crate::aws::s3::read_file; |
|
|
|
|
use crate::config::get_config; |
|
|
|
|
|
|
|
|
|
static CONNECTION_POOL: OnceCell<Arc<Pool>> = OnceCell::const_new(); |
|
|
|
|
@ -32,11 +33,11 @@ async fn initialize_campaign_connection_pool() -> Arc<Pool> {
|
|
|
|
|
let config = get_config().await; |
|
|
|
|
|
|
|
|
|
let mut pg = Config::new(); |
|
|
|
|
pg.host = Some(config.database.host.clone()); |
|
|
|
|
pg.user = Some(config.database.user.clone()); |
|
|
|
|
pg.password = Some(config.database.password.clone()); |
|
|
|
|
pg.dbname = Some(config.database.name.clone()); |
|
|
|
|
pg.port = Some(config.database.port as u16); |
|
|
|
|
pg.host = Some(config.campaign_database.host.clone()); |
|
|
|
|
pg.user = Some(config.campaign_database.user.clone()); |
|
|
|
|
pg.password = Some(config.campaign_database.password.clone()); |
|
|
|
|
pg.dbname = Some(config.campaign_database.name.clone()); |
|
|
|
|
pg.port = Some(config.campaign_database.port as u16); |
|
|
|
|
|
|
|
|
|
let pool = pg.create_pool(Some(Runtime::Tokio1), NoTls).unwrap(); |
|
|
|
|
|
|
|
|
|
|