refactor(scheduler): move scheduler to new crate to support workflows in multiple crates (#1681)

This commit is contained in:
Jagan
2023-09-06 13:11:09 +05:30
committed by GitHub
parent ec4652ec09
commit d4221f3368
72 changed files with 1966 additions and 1124 deletions

View File

@ -15,6 +15,7 @@ use error_stack::{IntoReport, ResultExt};
use futures::future::join_all;
use masking::Secret;
use router_env::{instrument, tracing};
use scheduler::{db::process_tracker::ProcessTrackerExt, errors as sch_errors, utils as pt_utils};
use time;
pub use self::operations::{
@ -33,13 +34,13 @@ use crate::{
db::StorageInterface,
logger,
routes::{metrics, payment_methods::ParentPaymentMethodToken, AppState},
scheduler::{utils as pt_utils, workflows::payment_sync},
services::{self, api::Authenticate},
types::{
self as router_types, api, domain,
storage::{self, enums as storage_enums, ProcessTrackerExt},
storage::{self, enums as storage_enums},
},
utils::{add_connector_http_status_code_metrics, Encode, OptionExt, ValueExt},
workflows::payment_sync,
};
#[instrument(skip_all, fields(payment_id, merchant_id))]
@ -1412,7 +1413,7 @@ pub async fn add_process_sync_task(
db: &dyn StorageInterface,
payment_attempt: &storage::PaymentAttempt,
schedule_time: time::PrimitiveDateTime,
) -> Result<(), errors::ProcessTrackerError> {
) -> Result<(), sch_errors::ProcessTrackerError> {
let tracking_data = api::PaymentsRetrieveRequest {
force_sync: true,
merchant_id: Some(payment_attempt.merchant_id.clone()),
@ -1456,7 +1457,9 @@ pub async fn reset_process_sync_task(
.find_process_by_id(&process_tracker_id)
.await?
.ok_or(errors::ProcessTrackerError::ProcessFetchingFailed)?;
psync_process.reset(db, schedule_time).await?;
psync_process
.reset(db.as_scheduler(), schedule_time)
.await?;
Ok(())
}