29 lines
678 B
Rust
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()
|
|
}
|
|
}
|