mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
feat(scheduler): default connector mapping for adding process
This commit is contained in:
committed by
Sanchith Hegde
parent
2a2febb0f8
commit
4f74b65b71
@ -25,3 +25,17 @@ pub struct ConnectorPTMapping {
|
|||||||
pub custom_merchant_mapping: HashMap<String, RetryMapping>,
|
pub custom_merchant_mapping: HashMap<String, RetryMapping>,
|
||||||
pub max_retries_count: i32,
|
pub max_retries_count: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ConnectorPTMapping {
|
||||||
|
pub fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
custom_merchant_mapping: HashMap::new(),
|
||||||
|
default_mapping: RetryMapping {
|
||||||
|
start_after: 60,
|
||||||
|
frequency: vec![300],
|
||||||
|
count: vec![5],
|
||||||
|
},
|
||||||
|
max_retries_count: 5,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -93,9 +93,14 @@ pub async fn get_sync_process_schedule_time(
|
|||||||
redis: sync::Arc<redis::RedisConnectionPool>,
|
redis: sync::Arc<redis::RedisConnectionPool>,
|
||||||
retry_count: i32,
|
retry_count: i32,
|
||||||
) -> Result<Option<time::PrimitiveDateTime>, errors::ProcessTrackerError> {
|
) -> Result<Option<time::PrimitiveDateTime>, errors::ProcessTrackerError> {
|
||||||
let mapping: process_data::ConnectorPTMapping = redis
|
let redis_mapping: errors::CustomResult<process_data::ConnectorPTMapping, errors::RedisError> =
|
||||||
.get_and_deserialize_key(connector, "ConnectorPTMapping")
|
redis
|
||||||
.await?;
|
.get_and_deserialize_key(&format!("pt_mapping_{}", connector), "ConnectorPTMapping")
|
||||||
|
.await;
|
||||||
|
let mapping = match redis_mapping {
|
||||||
|
Ok(x) => x,
|
||||||
|
Err(_) => process_data::ConnectorPTMapping::default(),
|
||||||
|
};
|
||||||
let time_delta = get_sync_schedule_time(mapping, merchant_id, retry_count + 1);
|
let time_delta = get_sync_schedule_time(mapping, merchant_id, retry_count + 1);
|
||||||
|
|
||||||
Ok(pt_utils::get_time_from_delta(time_delta))
|
Ok(pt_utils::get_time_from_delta(time_delta))
|
||||||
|
|||||||
Reference in New Issue
Block a user