mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 09:07:09 +08:00
feat(core): introduce accounts schema for accounts related tables (#7113)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -20,11 +20,14 @@ pub trait DatabaseStore: Clone + Send + Sync {
|
||||
) -> StorageResult<Self>;
|
||||
fn get_master_pool(&self) -> &PgPool;
|
||||
fn get_replica_pool(&self) -> &PgPool;
|
||||
fn get_accounts_master_pool(&self) -> &PgPool;
|
||||
fn get_accounts_replica_pool(&self) -> &PgPool;
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Store {
|
||||
pub master_pool: PgPool,
|
||||
pub accounts_pool: PgPool,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
@ -38,6 +41,12 @@ impl DatabaseStore for Store {
|
||||
Ok(Self {
|
||||
master_pool: diesel_make_pg_pool(&config, tenant_config.get_schema(), test_transaction)
|
||||
.await?,
|
||||
accounts_pool: diesel_make_pg_pool(
|
||||
&config,
|
||||
tenant_config.get_accounts_schema(),
|
||||
test_transaction,
|
||||
)
|
||||
.await?,
|
||||
})
|
||||
}
|
||||
|
||||
@ -48,12 +57,22 @@ impl DatabaseStore for Store {
|
||||
fn get_replica_pool(&self) -> &PgPool {
|
||||
&self.master_pool
|
||||
}
|
||||
|
||||
fn get_accounts_master_pool(&self) -> &PgPool {
|
||||
&self.accounts_pool
|
||||
}
|
||||
|
||||
fn get_accounts_replica_pool(&self) -> &PgPool {
|
||||
&self.accounts_pool
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ReplicaStore {
|
||||
pub master_pool: PgPool,
|
||||
pub replica_pool: PgPool,
|
||||
pub accounts_master_pool: PgPool,
|
||||
pub accounts_replica_pool: PgPool,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
@ -69,6 +88,13 @@ impl DatabaseStore for ReplicaStore {
|
||||
diesel_make_pg_pool(&master_config, tenant_config.get_schema(), test_transaction)
|
||||
.await
|
||||
.attach_printable("failed to create master pool")?;
|
||||
let accounts_master_pool = diesel_make_pg_pool(
|
||||
&master_config,
|
||||
tenant_config.get_accounts_schema(),
|
||||
test_transaction,
|
||||
)
|
||||
.await
|
||||
.attach_printable("failed to create accounts master pool")?;
|
||||
let replica_pool = diesel_make_pg_pool(
|
||||
&replica_config,
|
||||
tenant_config.get_schema(),
|
||||
@ -76,9 +102,19 @@ impl DatabaseStore for ReplicaStore {
|
||||
)
|
||||
.await
|
||||
.attach_printable("failed to create replica pool")?;
|
||||
|
||||
let accounts_replica_pool = diesel_make_pg_pool(
|
||||
&replica_config,
|
||||
tenant_config.get_accounts_schema(),
|
||||
test_transaction,
|
||||
)
|
||||
.await
|
||||
.attach_printable("failed to create accounts pool")?;
|
||||
Ok(Self {
|
||||
master_pool,
|
||||
replica_pool,
|
||||
accounts_master_pool,
|
||||
accounts_replica_pool,
|
||||
})
|
||||
}
|
||||
|
||||
@ -89,6 +125,14 @@ impl DatabaseStore for ReplicaStore {
|
||||
fn get_replica_pool(&self) -> &PgPool {
|
||||
&self.replica_pool
|
||||
}
|
||||
|
||||
fn get_accounts_master_pool(&self) -> &PgPool {
|
||||
&self.accounts_master_pool
|
||||
}
|
||||
|
||||
fn get_accounts_replica_pool(&self) -> &PgPool {
|
||||
&self.accounts_replica_pool
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn diesel_make_pg_pool(
|
||||
|
||||
Reference in New Issue
Block a user