feat(scheduler): default connector mapping for adding process

This commit is contained in:
Nishant Joshi
2022-11-21 13:24:55 +00:00
committed by Sanchith Hegde
parent 2a2febb0f8
commit 4f74b65b71
2 changed files with 22 additions and 3 deletions

View File

@ -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,
}
}
}

View File

@ -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))