ForgeFlux/src/auth/adapter/out/db/mod.rs
Aravinth Manivannan 36f1c1e0f4
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
feat: test with mocks
2024-05-06 19:42:40 +05:30

29 lines
678 B
Rust

use std::sync::Arc;
use sqlx::PgPool;
use crate::auth::application::port::out::db::save_oauth_state::SaveOAuthState;
use crate::db::migrate::RunMigrations;
pub mod postgres;
#[derive(Clone)]
pub struct DBAdapter {
pub save_oauth_state_adapter: Arc<dyn SaveOAuthState>,
pg_adapter: postgres::DBOutPostgresAdapter,
}
impl DBAdapter {
pub fn new(pool: PgPool) -> Self {
let pg_adapter = postgres::DBOutPostgresAdapter::new(pool);
Self {
save_oauth_state_adapter: Arc::new(pg_adapter.clone()),
pg_adapter,
}
}
pub fn migratable(&self) -> Arc<dyn RunMigrations> {
self.pg_adapter.migratable()
}
}