mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 01:57:45 +08:00 
			
		
		
		
	refactor: get connection pool based on olap/oltp features (#743)
This commit is contained in:
		| @ -2,7 +2,7 @@ use error_stack::IntoReport; | ||||
|  | ||||
| use super::{MockDb, Store}; | ||||
| use crate::{ | ||||
|     connection::pg_connection, | ||||
|     connection, | ||||
|     core::errors::{self, CustomResult}, | ||||
|     types::storage, | ||||
| }; | ||||
| @ -46,7 +46,7 @@ impl ApiKeyInterface for Store { | ||||
|         &self, | ||||
|         api_key: storage::ApiKeyNew, | ||||
|     ) -> CustomResult<storage::ApiKey, errors::StorageError> { | ||||
|         let conn = pg_connection(&self.master_pool).await?; | ||||
|         let conn = connection::pg_connection_write(self).await?; | ||||
|         api_key | ||||
|             .insert(&conn) | ||||
|             .await | ||||
| @ -59,7 +59,7 @@ impl ApiKeyInterface for Store { | ||||
|         key_id: String, | ||||
|         api_key: storage::ApiKeyUpdate, | ||||
|     ) -> CustomResult<storage::ApiKey, errors::StorageError> { | ||||
|         let conn = pg_connection(&self.master_pool).await?; | ||||
|         let conn = connection::pg_connection_write(self).await?; | ||||
|         storage::ApiKey::update_by_key_id(&conn, key_id, api_key) | ||||
|             .await | ||||
|             .map_err(Into::into) | ||||
| @ -67,7 +67,7 @@ impl ApiKeyInterface for Store { | ||||
|     } | ||||
|  | ||||
|     async fn revoke_api_key(&self, key_id: &str) -> CustomResult<bool, errors::StorageError> { | ||||
|         let conn = pg_connection(&self.master_pool).await?; | ||||
|         let conn = connection::pg_connection_write(self).await?; | ||||
|         storage::ApiKey::revoke_by_key_id(&conn, key_id) | ||||
|             .await | ||||
|             .map_err(Into::into) | ||||
| @ -78,7 +78,7 @@ impl ApiKeyInterface for Store { | ||||
|         &self, | ||||
|         key_id: &str, | ||||
|     ) -> CustomResult<Option<storage::ApiKey>, errors::StorageError> { | ||||
|         let conn = pg_connection(&self.master_pool).await?; | ||||
|         let conn = connection::pg_connection_read(self).await?; | ||||
|         storage::ApiKey::find_optional_by_key_id(&conn, key_id) | ||||
|             .await | ||||
|             .map_err(Into::into) | ||||
| @ -89,7 +89,7 @@ impl ApiKeyInterface for Store { | ||||
|         &self, | ||||
|         hashed_api_key: storage::HashedApiKey, | ||||
|     ) -> CustomResult<Option<storage::ApiKey>, errors::StorageError> { | ||||
|         let conn = pg_connection(&self.master_pool).await?; | ||||
|         let conn = connection::pg_connection_read(self).await?; | ||||
|         storage::ApiKey::find_optional_by_hashed_api_key(&conn, hashed_api_key) | ||||
|             .await | ||||
|             .map_err(Into::into) | ||||
| @ -102,7 +102,7 @@ impl ApiKeyInterface for Store { | ||||
|         limit: Option<i64>, | ||||
|         offset: Option<i64>, | ||||
|     ) -> CustomResult<Vec<storage::ApiKey>, errors::StorageError> { | ||||
|         let conn = pg_connection(&self.master_pool).await?; | ||||
|         let conn = connection::pg_connection_read(self).await?; | ||||
|         storage::ApiKey::find_by_merchant_id(&conn, merchant_id, limit, offset) | ||||
|             .await | ||||
|             .map_err(Into::into) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Kartikeya Hegde
					Kartikeya Hegde