mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 01:57:45 +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:
		| @ -48,6 +48,32 @@ pub async fn pg_connection_read<T: storage_impl::DatabaseStore>( | ||||
|         .change_context(storage_errors::StorageError::DatabaseConnectionError) | ||||
| } | ||||
|  | ||||
| pub async fn pg_accounts_connection_read<T: storage_impl::DatabaseStore>( | ||||
|     store: &T, | ||||
| ) -> errors::CustomResult< | ||||
|     PooledConnection<'_, async_bb8_diesel::ConnectionManager<PgConnection>>, | ||||
|     storage_errors::StorageError, | ||||
| > { | ||||
|     // If only OLAP is enabled get replica pool. | ||||
|     #[cfg(all(feature = "olap", not(feature = "oltp")))] | ||||
|     let pool = store.get_accounts_replica_pool(); | ||||
|  | ||||
|     // If either one of these are true we need to get master pool. | ||||
|     //  1. Only OLTP is enabled. | ||||
|     //  2. Both OLAP and OLTP is enabled. | ||||
|     //  3. Both OLAP and OLTP is disabled. | ||||
|     #[cfg(any( | ||||
|         all(not(feature = "olap"), feature = "oltp"), | ||||
|         all(feature = "olap", feature = "oltp"), | ||||
|         all(not(feature = "olap"), not(feature = "oltp")) | ||||
|     ))] | ||||
|     let pool = store.get_accounts_master_pool(); | ||||
|  | ||||
|     pool.get() | ||||
|         .await | ||||
|         .change_context(storage_errors::StorageError::DatabaseConnectionError) | ||||
| } | ||||
|  | ||||
| pub async fn pg_connection_write<T: storage_impl::DatabaseStore>( | ||||
|     store: &T, | ||||
| ) -> errors::CustomResult< | ||||
| @ -61,3 +87,17 @@ pub async fn pg_connection_write<T: storage_impl::DatabaseStore>( | ||||
|         .await | ||||
|         .change_context(storage_errors::StorageError::DatabaseConnectionError) | ||||
| } | ||||
|  | ||||
| pub async fn pg_accounts_connection_write<T: storage_impl::DatabaseStore>( | ||||
|     store: &T, | ||||
| ) -> errors::CustomResult< | ||||
|     PooledConnection<'_, async_bb8_diesel::ConnectionManager<PgConnection>>, | ||||
|     storage_errors::StorageError, | ||||
| > { | ||||
|     // Since all writes should happen to master DB only choose master DB. | ||||
|     let pool = store.get_accounts_master_pool(); | ||||
|  | ||||
|     pool.get() | ||||
|         .await | ||||
|         .change_context(storage_errors::StorageError::DatabaseConnectionError) | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Hrithikesh
					Hrithikesh