id stringlengths 20 153 | type stringclasses 1
value | granularity stringclasses 14
values | content stringlengths 16 84.3k | metadata dict |
|---|---|---|---|---|
hyperswitch_fn_storage_impl_1709998043494806247 | clm | function | // hyperswitch/crates/storage_impl/src/merchant_connector_account.rs
async fn find_by_merchant_connector_account_merchant_id_merchant_connector_id(
&self,
state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
merchant_connector_id: &common_utils::id_type::MerchantConnectorAccountId,
key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, StorageError> {
match self
.merchant_connector_accounts
.lock()
.await
.iter()
.find(|account| {
account.merchant_id == *merchant_id
&& account.merchant_connector_id == *merchant_connector_id
})
.cloned()
.async_map(|account| async {
account
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)
})
.await
{
Some(result) => result,
None => {
return Err(StorageError::ValueNotFound(
"cannot find merchant connector account".to_string(),
)
.into())
}
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_by_merchant_connector_account_merchant_id_merchant_connector_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-3790695156150593222 | clm | function | // hyperswitch/crates/storage_impl/src/merchant_connector_account.rs
async fn find_merchant_connector_account_by_id(
&self,
state: &KeyManagerState,
id: &common_utils::id_type::MerchantConnectorAccountId,
key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, StorageError> {
match self
.merchant_connector_accounts
.lock()
.await
.iter()
.find(|account| account.get_id() == *id)
.cloned()
.async_map(|account| async {
account
.convert(
state,
key_store.key.get_inner(),
common_utils::types::keymanager::Identifier::Merchant(
key_store.merchant_id.clone(),
),
)
.await
.change_context(StorageError::DecryptionError)
})
.await
{
Some(result) => result,
None => {
return Err(StorageError::ValueNotFound(
"cannot find merchant connector account".to_string(),
)
.into())
}
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_merchant_connector_account_by_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-8813843045660168240 | clm | function | // hyperswitch/crates/storage_impl/src/merchant_connector_account.rs
async fn insert_merchant_connector_account(
&self,
state: &KeyManagerState,
t: domain::MerchantConnectorAccount,
key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, StorageError> {
let mut accounts = self.merchant_connector_accounts.lock().await;
let account = storage::MerchantConnectorAccount {
id: t.id,
merchant_id: t.merchant_id,
connector_name: t.connector_name,
connector_account_details: t.connector_account_details.into(),
disabled: t.disabled,
payment_methods_enabled: t.payment_methods_enabled,
metadata: t.metadata,
frm_config: t.frm_configs,
connector_type: t.connector_type,
connector_label: t.connector_label,
created_at: common_utils::date_time::now(),
modified_at: common_utils::date_time::now(),
connector_webhook_details: t.connector_webhook_details,
profile_id: t.profile_id,
applepay_verified_domains: t.applepay_verified_domains,
pm_auth_config: t.pm_auth_config,
status: t.status,
connector_wallets_details: t.connector_wallets_details.map(Encryption::from),
additional_merchant_data: t.additional_merchant_data.map(|data| data.into()),
version: t.version,
feature_metadata: t.feature_metadata.map(From::from),
};
accounts.push(account.clone());
account
.convert(
state,
key_store.key.get_inner(),
common_utils::types::keymanager::Identifier::Merchant(
key_store.merchant_id.clone(),
),
)
.await
.change_context(StorageError::DecryptionError)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "insert_merchant_connector_account",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_5923942997911658765 | clm | function | // hyperswitch/crates/storage_impl/src/merchant_connector_account.rs
async fn list_enabled_connector_accounts_by_profile_id(
&self,
_state: &KeyManagerState,
_profile_id: &common_utils::id_type::ProfileId,
_key_store: &MerchantKeyStore,
_connector_type: common_enums::ConnectorType,
) -> CustomResult<Vec<domain::MerchantConnectorAccount>, StorageError> {
Err(StorageError::MockDbError)?
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "list_enabled_connector_accounts_by_profile_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_6438454924072470650 | clm | function | // hyperswitch/crates/storage_impl/src/merchant_connector_account.rs
async fn find_merchant_connector_account_by_merchant_id_and_disabled_list(
&self,
state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
get_disabled: bool,
key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccounts, StorageError> {
let accounts = self
.merchant_connector_accounts
.lock()
.await
.iter()
.filter(|account: &&storage::MerchantConnectorAccount| {
if get_disabled {
account.merchant_id == *merchant_id
} else {
account.merchant_id == *merchant_id && account.disabled == Some(false)
}
})
.cloned()
.collect::<Vec<storage::MerchantConnectorAccount>>();
let mut output = Vec::with_capacity(accounts.len());
for account in accounts.into_iter() {
output.push(
account
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)?,
)
}
Ok(domain::MerchantConnectorAccounts::new(output))
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_merchant_connector_account_by_merchant_id_and_disabled_list",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_7309711427096432670 | clm | function | // hyperswitch/crates/storage_impl/src/merchant_connector_account.rs
async fn list_connector_account_by_profile_id(
&self,
state: &KeyManagerState,
profile_id: &common_utils::id_type::ProfileId,
key_store: &MerchantKeyStore,
) -> CustomResult<Vec<domain::MerchantConnectorAccount>, StorageError> {
let accounts = self
.merchant_connector_accounts
.lock()
.await
.iter()
.filter(|account: &&storage::MerchantConnectorAccount| {
account.profile_id == *profile_id
})
.cloned()
.collect::<Vec<storage::MerchantConnectorAccount>>();
let mut output = Vec::with_capacity(accounts.len());
for account in accounts.into_iter() {
output.push(
account
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)?,
)
}
Ok(output)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "list_connector_account_by_profile_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_8741715526761148519 | clm | function | // hyperswitch/crates/storage_impl/src/merchant_connector_account.rs
async fn update_multiple_merchant_connector_accounts(
&self,
_merchant_connector_accounts: Vec<(
domain::MerchantConnectorAccount,
storage::MerchantConnectorAccountUpdateInternal,
)>,
) -> CustomResult<(), StorageError> {
// No need to implement this function for `MockDb` as this function will be removed after the
// apple pay certificate migration
Err(StorageError::MockDbError)?
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "update_multiple_merchant_connector_accounts",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-6436779582278058127 | clm | function | // hyperswitch/crates/storage_impl/src/merchant_connector_account.rs
async fn update_merchant_connector_account(
&self,
state: &KeyManagerState,
this: domain::MerchantConnectorAccount,
merchant_connector_account: storage::MerchantConnectorAccountUpdateInternal,
key_store: &MerchantKeyStore,
) -> CustomResult<domain::MerchantConnectorAccount, StorageError> {
let mca_update_res = self
.merchant_connector_accounts
.lock()
.await
.iter_mut()
.find(|account| account.get_id() == this.get_id())
.map(|a| {
let updated =
merchant_connector_account.create_merchant_connector_account(a.clone());
*a = updated.clone();
updated
})
.async_map(|account| async {
account
.convert(
state,
key_store.key.get_inner(),
common_utils::types::keymanager::Identifier::Merchant(
key_store.merchant_id.clone(),
),
)
.await
.change_context(StorageError::DecryptionError)
})
.await;
match mca_update_res {
Some(result) => result,
None => {
return Err(StorageError::ValueNotFound(
"cannot find merchant connector account to update".to_string(),
)
.into())
}
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "update_merchant_connector_account",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-874572487896174383 | clm | function | // hyperswitch/crates/storage_impl/src/merchant_connector_account.rs
async fn delete_merchant_connector_account_by_merchant_id_merchant_connector_id(
&self,
merchant_id: &common_utils::id_type::MerchantId,
merchant_connector_id: &common_utils::id_type::MerchantConnectorAccountId,
) -> CustomResult<bool, StorageError> {
let mut accounts = self.merchant_connector_accounts.lock().await;
match accounts.iter().position(|account| {
account.merchant_id == *merchant_id
&& account.merchant_connector_id == *merchant_connector_id
}) {
Some(index) => {
accounts.remove(index);
return Ok(true);
}
None => {
return Err(StorageError::ValueNotFound(
"cannot find merchant connector account to delete".to_string(),
)
.into())
}
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "delete_merchant_connector_account_by_merchant_id_merchant_connector_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-5865488104310578600 | clm | function | // hyperswitch/crates/storage_impl/src/merchant_connector_account.rs
async fn delete_merchant_connector_account_by_id(
&self,
id: &common_utils::id_type::MerchantConnectorAccountId,
) -> CustomResult<bool, StorageError> {
let mut accounts = self.merchant_connector_accounts.lock().await;
match accounts.iter().position(|account| account.get_id() == *id) {
Some(index) => {
accounts.remove(index);
return Ok(true);
}
None => {
return Err(StorageError::ValueNotFound(
"cannot find merchant connector account to delete".to_string(),
)
.into())
}
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "delete_merchant_connector_account_by_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-7475578111503230108 | clm | function | // hyperswitch/crates/storage_impl/src/merchant_connector_account.rs
async fn update_call(
connection: &diesel_models::PgPooledConn,
(merchant_connector_account, mca_update): (
domain::MerchantConnectorAccount,
storage::MerchantConnectorAccountUpdateInternal,
),
) -> Result<(), error_stack::Report<StorageError>> {
Conversion::convert(merchant_connector_account)
.await
.change_context(StorageError::EncryptionError)?
.update(connection, mca_update)
.await
.map_err(|error| report!(StorageError::from(error)))?;
Ok(())
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "update_call",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_2021561032744124237 | clm | function | // hyperswitch/crates/storage_impl/src/config.rs
fn get_username(&self) -> &str {
&self.username
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_username",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_4535046128315512430 | clm | function | // hyperswitch/crates/storage_impl/src/config.rs
fn get_password(&self) -> Secret<String> {
self.password.clone()
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_password",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-1812255908611463100 | clm | function | // hyperswitch/crates/storage_impl/src/config.rs
fn get_host(&self) -> &str {
&self.host
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_host",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_4191776316909751033 | clm | function | // hyperswitch/crates/storage_impl/src/config.rs
fn get_port(&self) -> u16 {
self.port
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_port",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-976569250898631304 | clm | function | // hyperswitch/crates/storage_impl/src/config.rs
fn get_dbname(&self) -> &str {
&self.dbname
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_dbname",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-8310843283607393510 | clm | function | // hyperswitch/crates/storage_impl/src/config.rs
fn from(value: QueueStrategy) -> Self {
match value {
QueueStrategy::Fifo => Self::Fifo,
QueueStrategy::Lifo => Self::Lifo,
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_3411409699748190427 | clm | function | // hyperswitch/crates/storage_impl/src/config.rs
fn default() -> Self {
Self {
username: String::new(),
password: Secret::<String>::default(),
host: "localhost".into(),
port: 5432,
dbname: String::new(),
pool_size: 5,
connection_timeout: 10,
queue_strategy: QueueStrategy::default(),
min_idle: None,
max_lifetime: None,
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "default",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_1793156777506370058 | clm | function | // hyperswitch/crates/storage_impl/src/config.rs
fn get_master_key(&self) -> &[u8] {
self.master_key()
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_master_key",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-7783363675851048987 | clm | function | // hyperswitch/crates/storage_impl/src/configs.rs
async fn insert_config(
&self,
config: storage::ConfigNew,
) -> CustomResult<storage::Config, Self::Error> {
let mut configs = self.configs.lock().await;
let config_new = storage::Config {
key: config.key,
config: config.config,
};
configs.push(config_new.clone());
Ok(config_new)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "insert_config",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-997487972342457904 | clm | function | // hyperswitch/crates/storage_impl/src/configs.rs
async fn update_config_in_database(
&self,
key: &str,
config_update: storage::ConfigUpdate,
) -> CustomResult<storage::Config, Self::Error> {
self.update_config_by_key(key, config_update).await
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "update_config_in_database",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-3048520113022375386 | clm | function | // hyperswitch/crates/storage_impl/src/configs.rs
async fn update_config_by_key(
&self,
key: &str,
config_update: storage::ConfigUpdate,
) -> CustomResult<storage::Config, Self::Error> {
let result = self
.configs
.lock()
.await
.iter_mut()
.find(|c| c.key == key)
.ok_or_else(|| {
StorageError::ValueNotFound("cannot find config to update".to_string()).into()
})
.map(|c| {
let config_updated =
ConfigUpdateInternal::from(config_update).create_config(c.clone());
*c = config_updated.clone();
config_updated
});
result
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "update_config_by_key",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_2872438215892302171 | clm | function | // hyperswitch/crates/storage_impl/src/configs.rs
async fn find_config_by_key_from_db(
&self,
key: &str,
) -> CustomResult<storage::Config, Self::Error> {
self.find_config_by_key(key).await
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_config_by_key_from_db",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_7208933378423935319 | clm | function | // hyperswitch/crates/storage_impl/src/configs.rs
async fn find_config_by_key(&self, key: &str) -> CustomResult<storage::Config, Self::Error> {
let configs = self.configs.lock().await;
let config = configs.iter().find(|c| c.key == key).cloned();
config.ok_or_else(|| StorageError::ValueNotFound("cannot find config".to_string()).into())
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_config_by_key",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_2578390292622007425 | clm | function | // hyperswitch/crates/storage_impl/src/configs.rs
async fn find_config_by_key_unwrap_or(
&self,
key: &str,
_default_config: Option<String>,
) -> CustomResult<storage::Config, Self::Error> {
self.find_config_by_key(key).await
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_config_by_key_unwrap_or",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_3923224750956680646 | clm | function | // hyperswitch/crates/storage_impl/src/configs.rs
async fn delete_config_by_key(&self, key: &str) -> CustomResult<storage::Config, Self::Error> {
let mut configs = self.configs.lock().await;
let result = configs
.iter()
.position(|c| c.key == key)
.map(|index| configs.remove(index))
.ok_or_else(|| {
StorageError::ValueNotFound("cannot find config to delete".to_string()).into()
});
result
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "delete_config_by_key",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_2430263232073704497 | clm | function | // hyperswitch/crates/storage_impl/src/lib.rs
async fn new(
config: Self::Config,
tenant_config: &dyn TenantConfig,
test_transaction: bool,
) -> error_stack::Result<Self, StorageError> {
let (db_conf, cache_conf, encryption_key, cache_error_signal, inmemory_cache_stream) =
config;
if test_transaction {
Self::test_store(db_conf, tenant_config, &cache_conf, encryption_key)
.await
.attach_printable("failed to create test router store")
} else {
Self::from_config(
db_conf,
tenant_config,
encryption_key,
Self::cache_store(&cache_conf, cache_error_signal).await?,
inmemory_cache_stream,
)
.await
.attach_printable("failed to create store")
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "new",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_987246441670330493 | clm | function | // hyperswitch/crates/storage_impl/src/lib.rs
fn get_master_pool(&self) -> &PgPool {
self.db_store.get_master_pool()
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_master_pool",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_1703094979687470569 | clm | function | // hyperswitch/crates/storage_impl/src/lib.rs
fn get_replica_pool(&self) -> &PgPool {
self.db_store.get_replica_pool()
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_replica_pool",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-4407865410619050725 | clm | function | // hyperswitch/crates/storage_impl/src/lib.rs
fn get_accounts_master_pool(&self) -> &PgPool {
self.db_store.get_accounts_master_pool()
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_accounts_master_pool",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_7260892923075016351 | clm | function | // hyperswitch/crates/storage_impl/src/lib.rs
fn get_accounts_replica_pool(&self) -> &PgPool {
self.db_store.get_accounts_replica_pool()
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_accounts_replica_pool",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-8661621719374007320 | clm | function | // hyperswitch/crates/storage_impl/src/lib.rs
fn get_redis_conn(&self) -> error_stack::Result<Arc<RedisConnectionPool>, RedisError> {
self.cache_store.get_redis_conn()
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_redis_conn",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_5337242216821576923 | clm | function | // hyperswitch/crates/storage_impl/src/lib.rs
pub async fn from_config(
db_conf: T::Config,
tenant_config: &dyn TenantConfig,
encryption_key: StrongSecret<Vec<u8>>,
cache_store: Arc<RedisStore>,
inmemory_cache_stream: &str,
) -> error_stack::Result<Self, StorageError> {
let db_store = T::new(db_conf, tenant_config, false).await?;
let redis_conn = cache_store.redis_conn.clone();
let cache_store = Arc::new(RedisStore {
redis_conn: Arc::new(RedisConnectionPool::clone(
&redis_conn,
tenant_config.get_redis_key_prefix(),
)),
});
cache_store
.redis_conn
.subscribe(inmemory_cache_stream)
.await
.change_context(StorageError::InitializationError)
.attach_printable("Failed to subscribe to inmemory cache stream")?;
Ok(Self {
db_store,
cache_store,
master_encryption_key: encryption_key,
request_id: None,
})
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from_config",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_9210744607918666388 | clm | function | // hyperswitch/crates/storage_impl/src/lib.rs
pub async fn cache_store(
cache_conf: &redis_interface::RedisSettings,
cache_error_signal: tokio::sync::oneshot::Sender<()>,
) -> error_stack::Result<Arc<RedisStore>, StorageError> {
let cache_store = RedisStore::new(cache_conf)
.await
.change_context(StorageError::InitializationError)
.attach_printable("Failed to create cache store")?;
cache_store.set_error_callback(cache_error_signal);
Ok(Arc::new(cache_store))
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "cache_store",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_1995487371901640543 | clm | function | // hyperswitch/crates/storage_impl/src/lib.rs
pub fn master_key(&self) -> &StrongSecret<Vec<u8>> {
&self.master_encryption_key
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "master_key",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-2022123553089966630 | clm | function | // hyperswitch/crates/storage_impl/src/lib.rs
pub async fn call_database<D, R, M>(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
execute_query: R,
) -> error_stack::Result<D, StorageError>
where
D: Debug + Sync + Conversion,
R: futures::Future<Output = error_stack::Result<M, diesel_models::errors::DatabaseError>>
+ Send,
M: ReverseConversion<D>,
{
execute_query
.await
.map_err(|error| {
let new_err = diesel_error_to_data_error(*error.current_context());
error.change_context(new_err)
})?
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "call_database",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_1914776084719927269 | clm | function | // hyperswitch/crates/storage_impl/src/lib.rs
pub async fn find_optional_resource<D, R, M>(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
execute_query_fut: R,
) -> error_stack::Result<Option<D>, StorageError>
where
D: Debug + Sync + Conversion,
R: futures::Future<
Output = error_stack::Result<Option<M>, diesel_models::errors::DatabaseError>,
> + Send,
M: ReverseConversion<D>,
{
match execute_query_fut.await.map_err(|error| {
let new_err = diesel_error_to_data_error(*error.current_context());
error.change_context(new_err)
})? {
Some(resource) => Ok(Some(
resource
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)?,
)),
None => Ok(None),
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_optional_resource",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_1660133662523608157 | clm | function | // hyperswitch/crates/storage_impl/src/lib.rs
pub async fn find_resources<D, R, M>(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
execute_query: R,
) -> error_stack::Result<Vec<D>, StorageError>
where
D: Debug + Sync + Conversion,
R: futures::Future<
Output = error_stack::Result<Vec<M>, diesel_models::errors::DatabaseError>,
> + Send,
M: ReverseConversion<D>,
{
let resource_futures = execute_query
.await
.map_err(|error| {
let new_err = diesel_error_to_data_error(*error.current_context());
error.change_context(new_err)
})?
.into_iter()
.map(|resource| async {
resource
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)
})
.collect::<Vec<_>>();
let resources = futures::future::try_join_all(resource_futures).await?;
Ok(resources)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_resources",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_908730038919888090 | clm | function | // hyperswitch/crates/storage_impl/src/lib.rs
pub async fn test_store(
db_conf: T::Config,
tenant_config: &dyn TenantConfig,
cache_conf: &redis_interface::RedisSettings,
encryption_key: StrongSecret<Vec<u8>>,
) -> error_stack::Result<Self, StorageError> {
// TODO: create an error enum and return proper error here
let db_store = T::new(db_conf, tenant_config, true).await?;
let cache_store = RedisStore::new(cache_conf)
.await
.change_context(StorageError::InitializationError)
.attach_printable("failed to create redis cache")?;
Ok(Self {
db_store,
cache_store: Arc::new(cache_store),
master_encryption_key: encryption_key,
request_id: None,
})
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "test_store",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-8314474965013643502 | clm | function | // hyperswitch/crates/storage_impl/src/lib.rs
pub(crate) fn diesel_error_to_data_error(
diesel_error: diesel_models::errors::DatabaseError,
) -> StorageError {
match diesel_error {
diesel_models::errors::DatabaseError::DatabaseConnectionError => {
StorageError::DatabaseConnectionError
}
diesel_models::errors::DatabaseError::NotFound => {
StorageError::ValueNotFound("Value not found".to_string())
}
diesel_models::errors::DatabaseError::UniqueViolation => StorageError::DuplicateValue {
entity: "entity ",
key: None,
},
_ => StorageError::DatabaseError(error_stack::report!(diesel_error)),
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "diesel_error_to_data_error",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-2898750585912296129 | clm | function | // hyperswitch/crates/storage_impl/src/lib.rs
async fn check_for_constraints(
&self,
redis_conn: &Arc<RedisConnectionPool>,
) -> CustomResult<(), RedisError> {
let constraints = self.unique_constraints();
let sadd_result = redis_conn
.sadd(
&format!("unique_constraint:{}", self.table_name()).into(),
constraints,
)
.await?;
match sadd_result {
SaddReply::KeyNotSet => Err(error_stack::report!(RedisError::SetAddMembersFailed)),
SaddReply::KeySet => Ok(()),
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "check_for_constraints",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-1641727499453611015 | clm | function | // hyperswitch/crates/storage_impl/src/lib.rs
fn unique_constraints(&self) -> Vec<String> {
vec![format!("id_{}", self.id.get_string_repr())]
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "unique_constraints",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-218781015221322115 | clm | function | // hyperswitch/crates/storage_impl/src/lib.rs
fn table_name(&self) -> &str {
"tokenization"
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "table_name",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_5562317323259115721 | clm | function | // hyperswitch/crates/storage_impl/src/subscription.rs
async fn insert_subscription_entry(
&self,
_state: &KeyManagerState,
_key_store: &MerchantKeyStore,
_subscription_new: DomainSubscription,
) -> CustomResult<DomainSubscription, StorageError> {
Err(StorageError::MockDbError)?
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "insert_subscription_entry",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-2479196938716567462 | clm | function | // hyperswitch/crates/storage_impl/src/subscription.rs
async fn find_by_merchant_id_subscription_id(
&self,
_state: &KeyManagerState,
_key_store: &MerchantKeyStore,
_merchant_id: &common_utils::id_type::MerchantId,
_subscription_id: String,
) -> CustomResult<DomainSubscription, StorageError> {
Err(StorageError::MockDbError)?
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_by_merchant_id_subscription_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-7879554435456230482 | clm | function | // hyperswitch/crates/storage_impl/src/subscription.rs
async fn update_subscription_entry(
&self,
_state: &KeyManagerState,
_key_store: &MerchantKeyStore,
_merchant_id: &common_utils::id_type::MerchantId,
_subscription_id: String,
_data: DomainSubscriptionUpdate,
) -> CustomResult<DomainSubscription, StorageError> {
Err(StorageError::MockDbError)?
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "update_subscription_entry",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-4496279528271080349 | clm | function | // hyperswitch/crates/storage_impl/src/business_profile.rs
async fn insert_business_profile(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
business_profile: domain::Profile,
) -> CustomResult<domain::Profile, StorageError> {
let stored_business_profile = Conversion::convert(business_profile)
.await
.change_context(StorageError::EncryptionError)?;
self.business_profiles
.lock()
.await
.push(stored_business_profile.clone());
stored_business_profile
.convert(
key_manager_state,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "insert_business_profile",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-476339266325370817 | clm | function | // hyperswitch/crates/storage_impl/src/business_profile.rs
async fn find_business_profile_by_profile_id(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
profile_id: &common_utils::id_type::ProfileId,
) -> CustomResult<domain::Profile, StorageError> {
self.business_profiles
.lock()
.await
.iter()
.find(|business_profile| business_profile.get_id() == profile_id)
.cloned()
.async_map(|business_profile| async {
business_profile
.convert(
key_manager_state,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)
})
.await
.transpose()?
.ok_or(
StorageError::ValueNotFound(format!(
"No business profile found for profile_id = {profile_id:?}"
))
.into(),
)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_business_profile_by_profile_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-7931131961040545572 | clm | function | // hyperswitch/crates/storage_impl/src/business_profile.rs
async fn find_business_profile_by_merchant_id_profile_id(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
merchant_id: &common_utils::id_type::MerchantId,
profile_id: &common_utils::id_type::ProfileId,
) -> CustomResult<domain::Profile, StorageError> {
self.business_profiles
.lock()
.await
.iter()
.find(|business_profile| {
business_profile.merchant_id == *merchant_id
&& business_profile.get_id() == profile_id
})
.cloned()
.async_map(|business_profile| async {
business_profile
.convert(
key_manager_state,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)
})
.await
.transpose()?
.ok_or(
StorageError::ValueNotFound(format!(
"No business profile found for merchant_id = {merchant_id:?} and profile_id = {profile_id:?}"
))
.into(),
)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_business_profile_by_merchant_id_profile_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_4243082239792549488 | clm | function | // hyperswitch/crates/storage_impl/src/business_profile.rs
async fn find_business_profile_by_profile_name_merchant_id(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
profile_name: &str,
merchant_id: &common_utils::id_type::MerchantId,
) -> CustomResult<domain::Profile, StorageError> {
self.business_profiles
.lock()
.await
.iter()
.find(|business_profile| {
business_profile.profile_name == profile_name
&& business_profile.merchant_id == *merchant_id
})
.cloned()
.async_map(|business_profile| async {
business_profile
.convert(
key_manager_state,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)
})
.await
.transpose()?
.ok_or(
StorageError::ValueNotFound(format!(
"No business profile found for profile_name = {profile_name} and merchant_id = {merchant_id:?}"
))
.into(),
)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_business_profile_by_profile_name_merchant_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-1587028305134078521 | clm | function | // hyperswitch/crates/storage_impl/src/business_profile.rs
async fn update_profile_by_profile_id(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
current_state: domain::Profile,
profile_update: domain::ProfileUpdate,
) -> CustomResult<domain::Profile, StorageError> {
let profile_id = current_state.get_id().to_owned();
self.business_profiles
.lock()
.await
.iter_mut()
.find(|business_profile| business_profile.get_id() == current_state.get_id())
.async_map(|business_profile| async {
let profile_updated = ProfileUpdateInternal::from(profile_update).apply_changeset(
Conversion::convert(current_state)
.await
.change_context(StorageError::EncryptionError)?,
);
*business_profile = profile_updated.clone();
profile_updated
.convert(
key_manager_state,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)
})
.await
.transpose()?
.ok_or(
StorageError::ValueNotFound(format!(
"No business profile found for profile_id = {profile_id:?}",
))
.into(),
)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "update_profile_by_profile_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_7287178810773622998 | clm | function | // hyperswitch/crates/storage_impl/src/business_profile.rs
async fn delete_profile_by_profile_id_merchant_id(
&self,
profile_id: &common_utils::id_type::ProfileId,
merchant_id: &common_utils::id_type::MerchantId,
) -> CustomResult<bool, StorageError> {
let mut business_profiles = self.business_profiles.lock().await;
let index = business_profiles
.iter()
.position(|business_profile| {
business_profile.get_id() == profile_id
&& business_profile.merchant_id == *merchant_id
})
.ok_or::<StorageError>(StorageError::ValueNotFound(format!(
"No business profile found for profile_id = {profile_id:?} and merchant_id = {merchant_id:?}"
)))?;
business_profiles.remove(index);
Ok(true)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "delete_profile_by_profile_id_merchant_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_8156647139998234421 | clm | function | // hyperswitch/crates/storage_impl/src/business_profile.rs
async fn list_profile_by_merchant_id(
&self,
key_manager_state: &KeyManagerState,
merchant_key_store: &MerchantKeyStore,
merchant_id: &common_utils::id_type::MerchantId,
) -> CustomResult<Vec<domain::Profile>, StorageError> {
let business_profiles = self
.business_profiles
.lock()
.await
.iter()
.filter(|business_profile| business_profile.merchant_id == *merchant_id)
.cloned()
.collect::<Vec<_>>();
let mut domain_business_profiles = Vec::with_capacity(business_profiles.len());
for business_profile in business_profiles {
let domain_profile = business_profile
.convert(
key_manager_state,
merchant_key_store.key.get_inner(),
merchant_key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)?;
domain_business_profiles.push(domain_profile);
}
Ok(domain_business_profiles)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "list_profile_by_merchant_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-4677916427953677208 | clm | function | // hyperswitch/crates/storage_impl/src/invoice.rs
async fn insert_invoice_entry(
&self,
_state: &KeyManagerState,
_key_store: &MerchantKeyStore,
_invoice_new: DomainInvoice,
) -> CustomResult<DomainInvoice, StorageError> {
Err(StorageError::MockDbError)?
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "insert_invoice_entry",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-4328353494244891391 | clm | function | // hyperswitch/crates/storage_impl/src/invoice.rs
async fn find_invoice_by_invoice_id(
&self,
_state: &KeyManagerState,
_key_store: &MerchantKeyStore,
_invoice_id: String,
) -> CustomResult<DomainInvoice, StorageError> {
Err(StorageError::MockDbError)?
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_invoice_by_invoice_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_8086334671796892668 | clm | function | // hyperswitch/crates/storage_impl/src/invoice.rs
async fn update_invoice_entry(
&self,
_state: &KeyManagerState,
_key_store: &MerchantKeyStore,
_invoice_id: String,
_data: DomainInvoiceUpdate,
) -> CustomResult<DomainInvoice, StorageError> {
Err(StorageError::MockDbError)?
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "update_invoice_entry",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_2110755367993982735 | clm | function | // hyperswitch/crates/storage_impl/src/invoice.rs
async fn get_latest_invoice_for_subscription(
&self,
_state: &KeyManagerState,
_key_store: &MerchantKeyStore,
_subscription_id: String,
) -> CustomResult<DomainInvoice, StorageError> {
Err(StorageError::MockDbError)?
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_latest_invoice_for_subscription",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-8720173737495894486 | clm | function | // hyperswitch/crates/storage_impl/src/invoice.rs
async fn find_invoice_by_subscription_id_connector_invoice_id(
&self,
_state: &KeyManagerState,
_key_store: &MerchantKeyStore,
_subscription_id: String,
_connector_invoice_id: common_utils::id_type::InvoiceId,
) -> CustomResult<Option<DomainInvoice>, StorageError> {
Err(StorageError::MockDbError)?
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_invoice_by_subscription_id_connector_invoice_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-5138845452465340418 | clm | function | // hyperswitch/crates/storage_impl/src/errors.rs
fn from(error: diesel::result::Error) -> Self {
match error {
diesel::result::Error::DatabaseError(_, _) => Self::DBError,
diesel::result::Error::RollbackErrorOnCommit { .. }
| diesel::result::Error::RollbackTransaction
| diesel::result::Error::AlreadyInTransaction
| diesel::result::Error::NotInTransaction
| diesel::result::Error::BrokenTransactionManager => Self::TransactionError,
_ => Self::UnknownError,
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-3913661460330741360 | clm | function | // hyperswitch/crates/storage_impl/src/errors.rs
pub fn is_db_not_found(&self) -> bool {
match self {
Self::DatabaseError(err) => matches!(err.current_context(), DatabaseError::NotFound),
Self::ValueNotFound(_) => true,
Self::RedisError(err) => matches!(err.current_context(), RedisError::NotFound),
_ => false,
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "is_db_not_found",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_6065001934800589615 | clm | function | // hyperswitch/crates/storage_impl/src/errors.rs
pub fn is_db_unique_violation(&self) -> bool {
match self {
Self::DatabaseError(err) => {
matches!(err.current_context(), DatabaseError::UniqueViolation,)
}
Self::DuplicateValue { .. } => true,
_ => false,
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "is_db_unique_violation",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_2997404509144743918 | clm | function | // hyperswitch/crates/storage_impl/src/errors.rs
fn to_redis_failed_response(self, key: &str) -> error_stack::Report<StorageError> {
match self.current_context() {
RedisError::NotFound => self.change_context(StorageError::ValueNotFound(format!(
"Data does not exist for key {key}",
))),
RedisError::SetNxFailed | RedisError::SetAddMembersFailed => {
self.change_context(StorageError::DuplicateValue {
entity: "redis",
key: Some(key.to_string()),
})
}
_ => self.change_context(StorageError::KVError),
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "to_redis_failed_response",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_8631828103665526600 | clm | function | // hyperswitch/crates/storage_impl/src/customers.rs
pub(super) fn get_global_id_label(global_customer_id: &id_type::GlobalCustomerId) -> String {
format!(
"customer_global_id_{}",
global_customer_id.get_string_repr()
)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_global_id_label",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-9173858635266981134 | clm | function | // hyperswitch/crates/storage_impl/src/customers.rs
pub(super) fn get_merchant_scoped_id_label(
merchant_id: &id_type::MerchantId,
merchant_reference_id: &id_type::CustomerId,
) -> String {
format!(
"customer_mid_{}_mrefid_{}",
merchant_id.get_string_repr(),
merchant_reference_id.get_string_repr()
)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_merchant_scoped_id_label",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_3825964141126874936 | clm | function | // hyperswitch/crates/storage_impl/src/customers.rs
async fn find_customer_optional_by_customer_id_merchant_id(
&self,
state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<Option<domain::Customer>, StorageError> {
let customers = self.customers.lock().await;
self.find_resource(state, key_store, customers, |customer| {
customer.customer_id == *customer_id && &customer.merchant_id == merchant_id
})
.await
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_customer_optional_by_customer_id_merchant_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_3407002041783766754 | clm | function | // hyperswitch/crates/storage_impl/src/customers.rs
async fn find_customer_optional_with_redacted_customer_details_by_customer_id_merchant_id(
&self,
state: &KeyManagerState,
customer_id: &id_type::CustomerId,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<Option<domain::Customer>, StorageError> {
let customers = self.customers.lock().await;
self.find_resource(state, key_store, customers, |customer| {
customer.customer_id == *customer_id && &customer.merchant_id == merchant_id
})
.await
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_customer_optional_with_redacted_customer_details_by_customer_id_merchant_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_4814730066163703402 | clm | function | // hyperswitch/crates/storage_impl/src/customers.rs
async fn find_optional_by_merchant_id_merchant_reference_id(
&self,
_state: &KeyManagerState,
_customer_id: &id_type::CustomerId,
_merchant_id: &id_type::MerchantId,
_key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<Option<domain::Customer>, StorageError> {
todo!()
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_optional_by_merchant_id_merchant_reference_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-7533631471430267764 | clm | function | // hyperswitch/crates/storage_impl/src/customers.rs
async fn update_customer_by_customer_id_merchant_id(
&self,
_state: &KeyManagerState,
_customer_id: id_type::CustomerId,
_merchant_id: id_type::MerchantId,
_customer: domain::Customer,
_customer_update: domain::CustomerUpdate,
_key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::Customer, StorageError> {
// [#172]: Implement function for `MockDb`
Err(StorageError::MockDbError)?
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "update_customer_by_customer_id_merchant_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-8813789992734199083 | clm | function | // hyperswitch/crates/storage_impl/src/customers.rs
async fn find_customer_by_merchant_reference_id_merchant_id(
&self,
_state: &KeyManagerState,
_merchant_reference_id: &id_type::CustomerId,
_merchant_id: &id_type::MerchantId,
_key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::Customer, StorageError> {
// [#172]: Implement function for `MockDb`
Err(StorageError::MockDbError)?
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_customer_by_merchant_reference_id_merchant_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-5681063322080557912 | clm | function | // hyperswitch/crates/storage_impl/src/customers.rs
async fn find_customer_by_customer_id_merchant_id(
&self,
_state: &KeyManagerState,
_customer_id: &id_type::CustomerId,
_merchant_id: &id_type::MerchantId,
_key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::Customer, StorageError> {
// [#172]: Implement function for `MockDb`
Err(StorageError::MockDbError)?
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_customer_by_customer_id_merchant_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_2586279726859992732 | clm | function | // hyperswitch/crates/storage_impl/src/customers.rs
async fn list_customers_by_merchant_id(
&self,
state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
constraints: domain::CustomerListConstraints,
) -> CustomResult<Vec<domain::Customer>, StorageError> {
let customers = self.customers.lock().await;
let customers = try_join_all(
customers
.iter()
.filter(|customer| customer.merchant_id == *merchant_id)
.take(usize::from(constraints.limit))
.skip(usize::try_from(constraints.offset.unwrap_or(0)).unwrap_or(0))
.map(|customer| async {
customer
.to_owned()
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)
}),
)
.await?;
Ok(customers)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "list_customers_by_merchant_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_1763744629021178493 | clm | function | // hyperswitch/crates/storage_impl/src/customers.rs
async fn list_customers_by_merchant_id_with_count(
&self,
state: &KeyManagerState,
merchant_id: &id_type::MerchantId,
key_store: &MerchantKeyStore,
constraints: domain::CustomerListConstraints,
) -> CustomResult<(Vec<domain::Customer>, usize), StorageError> {
let customers = self.customers.lock().await;
let customers_list = try_join_all(
customers
.iter()
.filter(|customer| customer.merchant_id == *merchant_id)
.take(usize::from(constraints.limit))
.skip(usize::try_from(constraints.offset.unwrap_or(0)).unwrap_or(0))
.map(|customer| async {
customer
.to_owned()
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)
}),
)
.await?;
let total_count = customers
.iter()
.filter(|customer| customer.merchant_id == *merchant_id)
.count();
Ok((customers_list, total_count))
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "list_customers_by_merchant_id_with_count",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-3239311826287629294 | clm | function | // hyperswitch/crates/storage_impl/src/customers.rs
async fn insert_customer(
&self,
customer_data: domain::Customer,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::Customer, StorageError> {
let mut customers = self.customers.lock().await;
let customer = Conversion::convert(customer_data)
.await
.change_context(StorageError::EncryptionError)?;
customers.push(customer.clone());
customer
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(StorageError::DecryptionError)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "insert_customer",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_4718818360914754953 | clm | function | // hyperswitch/crates/storage_impl/src/customers.rs
async fn delete_customer_by_customer_id_merchant_id(
&self,
_customer_id: &id_type::CustomerId,
_merchant_id: &id_type::MerchantId,
) -> CustomResult<bool, StorageError> {
// [#172]: Implement function for `MockDb`
Err(StorageError::MockDbError)?
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "delete_customer_by_customer_id_merchant_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-7242798513091594308 | clm | function | // hyperswitch/crates/storage_impl/src/customers.rs
async fn find_customer_by_global_id(
&self,
_state: &KeyManagerState,
_id: &id_type::GlobalCustomerId,
_key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::Customer, StorageError> {
// [#172]: Implement function for `MockDb`
Err(StorageError::MockDbError)?
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_customer_by_global_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-998467026918797577 | clm | function | // hyperswitch/crates/storage_impl/src/customers.rs
async fn update_customer_by_global_id(
&self,
_state: &KeyManagerState,
_id: &id_type::GlobalCustomerId,
_customer: domain::Customer,
_customer_update: domain::CustomerUpdate,
_key_store: &MerchantKeyStore,
_storage_scheme: MerchantStorageScheme,
) -> CustomResult<domain::Customer, StorageError> {
// [#172]: Implement function for `MockDb`
Err(StorageError::MockDbError)?
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "update_customer_by_global_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_6338682828846683374 | clm | function | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
async fn new(
config: Self::Config,
tenant_config: &dyn TenantConfig,
_test_transaction: bool,
) -> StorageResult<Self> {
let (router_store, _, drainer_num_partitions, ttl_for_kv, soft_kill_mode) = config;
let drainer_stream_name = format!("{}_{}", tenant_config.get_schema(), config.1);
Ok(Self::from_store(
router_store,
drainer_stream_name,
drainer_num_partitions,
ttl_for_kv,
soft_kill_mode,
))
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "new",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-6322699128218684826 | clm | function | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
fn get_master_pool(&self) -> &PgPool {
self.router_store.get_master_pool()
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_master_pool",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_7687795764613861142 | clm | function | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
fn get_replica_pool(&self) -> &PgPool {
self.router_store.get_replica_pool()
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_replica_pool",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-374702720514072423 | clm | function | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
fn get_accounts_master_pool(&self) -> &PgPool {
self.router_store.get_accounts_master_pool()
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_accounts_master_pool",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-6172537025729158110 | clm | function | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
fn get_accounts_replica_pool(&self) -> &PgPool {
self.router_store.get_accounts_replica_pool()
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_accounts_replica_pool",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-7239414451963100914 | clm | function | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
fn get_redis_conn(&self) -> error_stack::Result<Arc<RedisConnectionPool>, RedisError> {
self.router_store.get_redis_conn()
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_redis_conn",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-8719256394583608491 | clm | function | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
pub fn from_store(
store: RouterStore<T>,
drainer_stream_name: String,
drainer_num_partitions: u8,
ttl_for_kv: u32,
soft_kill: Option<bool>,
) -> Self {
let request_id = store.request_id.clone();
Self {
router_store: store,
drainer_stream_name,
drainer_num_partitions,
ttl_for_kv,
request_id,
soft_kill_mode: soft_kill.unwrap_or(false),
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "from_store",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_4666875002971712679 | clm | function | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
pub fn master_key(&self) -> &StrongSecret<Vec<u8>> {
self.router_store.master_key()
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "master_key",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-2514263065789036309 | clm | function | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
pub fn get_drainer_stream_name(&self, shard_key: &str) -> String {
format!("{{{}}}_{}", shard_key, self.drainer_stream_name)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_drainer_stream_name",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_4911298079700532536 | clm | function | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
pub async fn push_to_drainer_stream<R>(
&self,
redis_entry: kv::TypedSql,
partition_key: PartitionKey<'_>,
) -> error_stack::Result<(), RedisError>
where
R: KvStorePartition,
{
let global_id = format!("{partition_key}");
let request_id = self.request_id.clone().unwrap_or_default();
let shard_key = R::shard_key(partition_key, self.drainer_num_partitions);
let stream_name = self.get_drainer_stream_name(&shard_key);
self.router_store
.cache_store
.redis_conn
.stream_append_entry(
&stream_name.into(),
&redis_interface::RedisEntryId::AutoGeneratedID,
redis_entry
.to_field_value_pairs(request_id, global_id)
.change_context(RedisError::JsonSerializationFailed)?,
)
.await
.map(|_| metrics::KV_PUSHED_TO_DRAINER.add(1, &[]))
.inspect_err(|error| {
metrics::KV_FAILED_TO_PUSH_TO_DRAINER.add(1, &[]);
logger::error!(?error, "Failed to add entry in drainer stream");
})
.change_context(RedisError::StreamAppendFailed)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "push_to_drainer_stream",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_2121749778515321596 | clm | function | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
pub async fn find_resource_by_id<D, R, M>(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
find_resource_db_fut: R,
find_by: FindResourceBy<'_>,
) -> error_stack::Result<D, errors::StorageError>
where
D: DomainType,
M: StorageModel<D>,
R: futures::Future<Output = error_stack::Result<M, DatabaseError>> + Send,
{
let database_call = || async {
find_resource_db_fut.await.map_err(|error| {
let new_err = diesel_error_to_data_error(*error.current_context());
error.change_context(new_err)
})
};
let storage_scheme = Box::pin(decide_storage_scheme::<T, M>(
self,
storage_scheme,
Op::Find,
))
.await;
let res = || async {
match storage_scheme {
MerchantStorageScheme::PostgresOnly => database_call().await,
MerchantStorageScheme::RedisKv => {
let (field, key) = match find_by {
FindResourceBy::Id(field, key) => (field, key),
FindResourceBy::LookupId(lookup_id) => {
let lookup = fallback_reverse_lookup_not_found!(
self.get_lookup_by_lookup_id(&lookup_id, storage_scheme)
.await,
database_call().await
);
(
lookup.clone().sk_id,
PartitionKey::CombinationKey {
combination: &lookup.clone().pk_id,
},
)
}
};
Box::pin(try_redis_get_else_try_database_get(
async {
Box::pin(kv_wrapper(self, KvOperation::<M>::HGet(&field), key))
.await?
.try_into_hget()
},
database_call,
))
.await
}
}
};
res()
.await?
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(errors::StorageError::DecryptionError)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_resource_by_id",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-2079286931344911699 | clm | function | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
pub async fn find_optional_resource_by_id<D, R, M>(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
find_resource_db_fut: R,
find_by: FindResourceBy<'_>,
) -> error_stack::Result<Option<D>, errors::StorageError>
where
D: DomainType,
M: StorageModel<D>,
R: futures::Future<Output = error_stack::Result<Option<M>, DatabaseError>> + Send,
{
let database_call = || async {
find_resource_db_fut.await.map_err(|error| {
let new_err = diesel_error_to_data_error(*error.current_context());
error.change_context(new_err)
})
};
let storage_scheme = Box::pin(decide_storage_scheme::<T, M>(
self,
storage_scheme,
Op::Find,
))
.await;
let res = || async {
match storage_scheme {
MerchantStorageScheme::PostgresOnly => database_call().await,
MerchantStorageScheme::RedisKv => {
let (field, key) = match find_by {
FindResourceBy::Id(field, key) => (field, key),
FindResourceBy::LookupId(lookup_id) => {
let lookup = fallback_reverse_lookup_not_found!(
self.get_lookup_by_lookup_id(&lookup_id, storage_scheme)
.await,
database_call().await
);
(
lookup.clone().sk_id,
PartitionKey::CombinationKey {
combination: &lookup.clone().pk_id,
},
)
}
};
Box::pin(try_redis_get_else_try_database_get(
async {
Box::pin(kv_wrapper(self, KvOperation::<M>::HGet(&field), key))
.await?
.try_into_hget()
.map(Some)
},
database_call,
))
.await
}
}
};
match res().await? {
Some(resource) => Ok(Some(
resource
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(errors::StorageError::DecryptionError)?,
)),
None => Ok(None),
}
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "find_optional_resource_by_id",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-2475732871969245210 | clm | function | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
pub async fn insert_resource<D, R, M>(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
create_resource_fut: R,
resource_new: M,
InsertResourceParams {
insertable,
reverse_lookups,
key,
identifier,
resource_type,
}: InsertResourceParams<'_>,
) -> error_stack::Result<D, errors::StorageError>
where
D: Debug + Sync + Conversion,
M: StorageModel<D>,
R: futures::Future<Output = error_stack::Result<M, DatabaseError>> + Send,
{
let storage_scheme = Box::pin(decide_storage_scheme::<_, M>(
self,
storage_scheme,
Op::Insert,
))
.await;
match storage_scheme {
MerchantStorageScheme::PostgresOnly => create_resource_fut.await.map_err(|error| {
let new_err = diesel_error_to_data_error(*error.current_context());
error.change_context(new_err)
}),
MerchantStorageScheme::RedisKv => {
let key_str = key.to_string();
let reverse_lookup_entry = |v: String| diesel_models::ReverseLookupNew {
sk_id: identifier.clone(),
pk_id: key_str.clone(),
lookup_id: v,
source: resource_type.to_string(),
updated_by: storage_scheme.to_string(),
};
let results = reverse_lookups
.into_iter()
.map(|v| self.insert_reverse_lookup(reverse_lookup_entry(v), storage_scheme));
futures::future::try_join_all(results).await?;
let redis_entry = kv::TypedSql {
op: kv::DBOperation::Insert {
insertable: Box::new(insertable),
},
};
match Box::pin(kv_wrapper::<M, _, _>(
self,
KvOperation::<M>::HSetNx(&identifier, &resource_new, redis_entry),
key.clone(),
))
.await
.map_err(|err| err.to_redis_failed_response(&key.to_string()))?
.try_into_hsetnx()
{
Ok(HsetnxReply::KeyNotSet) => Err(errors::StorageError::DuplicateValue {
entity: resource_type,
key: Some(key_str),
}
.into()),
Ok(HsetnxReply::KeySet) => Ok(resource_new),
Err(er) => Err(er).change_context(errors::StorageError::KVError),
}
}
}?
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(errors::StorageError::DecryptionError)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "insert_resource",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-7338781005591829998 | clm | function | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
pub async fn update_resource<D, R, M>(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
update_resource_fut: R,
updated_resource: M,
UpdateResourceParams {
updateable,
operation,
}: UpdateResourceParams<'_>,
) -> error_stack::Result<D, errors::StorageError>
where
D: Debug + Sync + Conversion,
M: StorageModel<D>,
R: futures::Future<Output = error_stack::Result<M, DatabaseError>> + Send,
{
match operation {
Op::Update(key, field, updated_by) => {
let storage_scheme = Box::pin(decide_storage_scheme::<_, M>(
self,
storage_scheme,
Op::Update(key.clone(), field, updated_by),
))
.await;
match storage_scheme {
MerchantStorageScheme::PostgresOnly => {
update_resource_fut.await.map_err(|error| {
let new_err = diesel_error_to_data_error(*error.current_context());
error.change_context(new_err)
})
}
MerchantStorageScheme::RedisKv => {
let key_str = key.to_string();
let redis_value = serde_json::to_string(&updated_resource)
.change_context(errors::StorageError::SerializationFailed)?;
let redis_entry = kv::TypedSql {
op: kv::DBOperation::Update {
updatable: Box::new(updateable),
},
};
Box::pin(kv_wrapper::<(), _, _>(
self,
KvOperation::<M>::Hset((field, redis_value), redis_entry),
key,
))
.await
.map_err(|err| err.to_redis_failed_response(&key_str))?
.try_into_hset()
.change_context(errors::StorageError::KVError)?;
Ok(updated_resource)
}
}
}
_ => Err(errors::StorageError::KVError.into()),
}?
.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(errors::StorageError::DecryptionError)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "update_resource",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_161588773065180347 | clm | function | // hyperswitch/crates/storage_impl/src/kv_router_store.rs
pub async fn filter_resources<D, R, M>(
&self,
state: &KeyManagerState,
key_store: &MerchantKeyStore,
storage_scheme: MerchantStorageScheme,
filter_resource_db_fut: R,
filter_fn: impl Fn(&M) -> bool,
FilterResourceParams {
key,
pattern,
limit,
}: FilterResourceParams<'_>,
) -> error_stack::Result<Vec<D>, errors::StorageError>
where
D: Debug + Sync + Conversion,
M: StorageModel<D>,
R: futures::Future<Output = error_stack::Result<Vec<M>, DatabaseError>> + Send,
{
let db_call = || async {
filter_resource_db_fut.await.map_err(|error| {
let new_err = diesel_error_to_data_error(*error.current_context());
error.change_context(new_err)
})
};
let resources = match storage_scheme {
MerchantStorageScheme::PostgresOnly => db_call().await,
MerchantStorageScheme::RedisKv => {
let redis_fut = async {
let kv_result = Box::pin(kv_wrapper::<M, _, _>(
self,
KvOperation::<M>::Scan(pattern),
key,
))
.await?
.try_into_scan();
kv_result.map(|records| records.into_iter().filter(filter_fn).collect())
};
Box::pin(find_all_combined_kv_database(redis_fut, db_call, limit)).await
}
}?;
let resource_futures = resources
.into_iter()
.map(|pm| async {
pm.convert(
state,
key_store.key.get_inner(),
key_store.merchant_id.clone().into(),
)
.await
.change_context(errors::StorageError::DecryptionError)
})
.collect::<Vec<_>>();
futures::future::try_join_all(resource_futures).await
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "filter_resources",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_8666614383484403314 | clm | function | // hyperswitch/crates/storage_impl/src/merchant_key_store.rs
async fn insert_merchant_key_store(
&self,
state: &KeyManagerState,
merchant_key_store: domain::MerchantKeyStore,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::MerchantKeyStore, Self::Error> {
let mut locked_merchant_key_store = self.merchant_key_store.lock().await;
if locked_merchant_key_store
.iter()
.any(|merchant_key| merchant_key.merchant_id == merchant_key_store.merchant_id)
{
Err(StorageError::DuplicateValue {
entity: "merchant_key_store",
key: Some(merchant_key_store.merchant_id.get_string_repr().to_owned()),
})?;
}
let merchant_key = Conversion::convert(merchant_key_store)
.await
.change_context(StorageError::MockDbError)?;
locked_merchant_key_store.push(merchant_key.clone());
let merchant_id = merchant_key.merchant_id.clone();
merchant_key
.convert(state, key, merchant_id.into())
.await
.change_context(StorageError::DecryptionError)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "insert_merchant_key_store",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_5324200582678104563 | clm | function | // hyperswitch/crates/storage_impl/src/merchant_key_store.rs
async fn get_merchant_key_store_by_merchant_id(
&self,
state: &KeyManagerState,
merchant_id: &common_utils::id_type::MerchantId,
key: &Secret<Vec<u8>>,
) -> CustomResult<domain::MerchantKeyStore, StorageError> {
self.merchant_key_store
.lock()
.await
.iter()
.find(|merchant_key| merchant_key.merchant_id == *merchant_id)
.cloned()
.ok_or(StorageError::ValueNotFound(String::from(
"merchant_key_store",
)))?
.convert(state, key, merchant_id.clone().into())
.await
.change_context(StorageError::DecryptionError)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_merchant_key_store_by_merchant_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_523186267409747800 | clm | function | // hyperswitch/crates/storage_impl/src/merchant_key_store.rs
async fn delete_merchant_key_store_by_merchant_id(
&self,
merchant_id: &common_utils::id_type::MerchantId,
) -> CustomResult<bool, StorageError> {
let mut merchant_key_stores = self.merchant_key_store.lock().await;
let index = merchant_key_stores
.iter()
.position(|mks| mks.merchant_id == *merchant_id)
.ok_or(StorageError::ValueNotFound(format!(
"No merchant key store found for merchant_id = {merchant_id:?}",
)))?;
merchant_key_stores.remove(index);
Ok(true)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "delete_merchant_key_store_by_merchant_id",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_7762652772892842149 | clm | function | // hyperswitch/crates/storage_impl/src/merchant_key_store.rs
async fn list_multiple_key_stores(
&self,
state: &KeyManagerState,
merchant_ids: Vec<common_utils::id_type::MerchantId>,
key: &Secret<Vec<u8>>,
) -> CustomResult<Vec<domain::MerchantKeyStore>, StorageError> {
let merchant_key_stores = self.merchant_key_store.lock().await;
futures::future::try_join_all(
merchant_key_stores
.iter()
.filter(|merchant_key| merchant_ids.contains(&merchant_key.merchant_id))
.map(|merchant_key| async {
merchant_key
.to_owned()
.convert(state, key, merchant_key.merchant_id.clone().into())
.await
.change_context(StorageError::DecryptionError)
}),
)
.await
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "list_multiple_key_stores",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-3606467165566225395 | clm | function | // hyperswitch/crates/storage_impl/src/merchant_key_store.rs
async fn get_all_key_stores(
&self,
state: &KeyManagerState,
key: &Secret<Vec<u8>>,
_from: u32,
_to: u32,
) -> CustomResult<Vec<domain::MerchantKeyStore>, StorageError> {
let merchant_key_stores = self.merchant_key_store.lock().await;
futures::future::try_join_all(merchant_key_stores.iter().map(|merchant_key| async {
merchant_key
.to_owned()
.convert(state, key, merchant_key.merchant_id.clone().into())
.await
.change_context(StorageError::DecryptionError)
}))
.await
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "get_all_key_stores",
"is_async": false,
"is_pub": false,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-4955509465862913488 | clm | function | // hyperswitch/crates/storage_impl/src/connection.rs
pub async fn redis_connection(
redis: &redis_interface::RedisSettings,
) -> redis_interface::RedisConnectionPool {
redis_interface::RedisConnectionPool::new(redis)
.await
.expect("Failed to create Redis Connection Pool")
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "redis_connection",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_1719552810077402616 | clm | function | // hyperswitch/crates/storage_impl/src/connection.rs
pub async fn pg_connection_read<T: crate::DatabaseStore>(
store: &T,
) -> errors::CustomResult<
PooledConnection<'_, async_bb8_diesel::ConnectionManager<PgConnection>>,
crate::errors::StorageError,
> {
// If only OLAP is enabled get replica pool.
#[cfg(all(feature = "olap", not(feature = "oltp")))]
let pool = store.get_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_master_pool();
pool.get()
.await
.change_context(crate::errors::StorageError::DatabaseConnectionError)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "pg_connection_read",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-2958171894030234323 | clm | function | // hyperswitch/crates/storage_impl/src/connection.rs
pub async fn pg_connection_write<T: crate::DatabaseStore>(
store: &T,
) -> errors::CustomResult<
PooledConnection<'_, async_bb8_diesel::ConnectionManager<PgConnection>>,
crate::errors::StorageError,
> {
// Since all writes should happen to master DB only choose master DB.
let pool = store.get_master_pool();
pool.get()
.await
.change_context(crate::errors::StorageError::DatabaseConnectionError)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "pg_connection_write",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
hyperswitch_fn_storage_impl_-2921928569657615447 | clm | function | // hyperswitch/crates/storage_impl/src/utils.rs
pub async fn pg_connection_read<T: DatabaseStore>(
store: &T,
) -> error_stack::Result<
PooledConnection<'_, async_bb8_diesel::ConnectionManager<PgConnection>>,
StorageError,
> {
// If only OLAP is enabled get replica pool.
#[cfg(all(feature = "olap", not(feature = "oltp")))]
let pool = store.get_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_master_pool();
pool.get()
.await
.change_context(StorageError::DatabaseConnectionError)
}
| {
"chunk": null,
"crate": "storage_impl",
"enum_name": null,
"file_size": null,
"for_type": null,
"function_name": "pg_connection_read",
"is_async": false,
"is_pub": true,
"lines": null,
"method_name": null,
"num_enums": null,
"num_items": null,
"num_structs": null,
"repo": "hyperswitch",
"start_line": null,
"struct_name": null,
"total_crates": null,
"trait_name": null
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.