mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
fix: resolve TODO comments in storage models crate (#151)
This commit is contained in:
@ -31,7 +31,7 @@ pub trait ProcessTrackerInterface {
|
||||
&self,
|
||||
task_ids: Vec<String>,
|
||||
task_update: storage::ProcessTrackerUpdate,
|
||||
) -> CustomResult<Vec<storage::ProcessTracker>, errors::StorageError>;
|
||||
) -> CustomResult<usize, errors::StorageError>;
|
||||
async fn update_process_tracker(
|
||||
&self,
|
||||
this: storage::ProcessTracker,
|
||||
@ -136,7 +136,7 @@ impl ProcessTrackerInterface for Store {
|
||||
&self,
|
||||
task_ids: Vec<String>,
|
||||
task_update: storage::ProcessTrackerUpdate,
|
||||
) -> CustomResult<Vec<storage::ProcessTracker>, errors::StorageError> {
|
||||
) -> CustomResult<usize, errors::StorageError> {
|
||||
let conn = pg_connection(&self.master_pool).await;
|
||||
storage::ProcessTracker::update_process_status_by_ids(&conn, task_ids, task_update)
|
||||
.await
|
||||
@ -224,7 +224,7 @@ impl ProcessTrackerInterface for MockDb {
|
||||
&self,
|
||||
_task_ids: Vec<String>,
|
||||
_task_update: storage::ProcessTrackerUpdate,
|
||||
) -> CustomResult<Vec<storage::ProcessTracker>, errors::StorageError> {
|
||||
) -> CustomResult<usize, errors::StorageError> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ pub async fn fetch_consumer_tasks(
|
||||
) -> CustomResult<Vec<storage::ProcessTracker>, errors::ProcessTrackerError> {
|
||||
let batches = pt_utils::get_batches(redis_conn, stream_name, group_name, consumer_name).await?;
|
||||
|
||||
let tasks = batches.into_iter().fold(Vec::new(), |mut acc, batch| {
|
||||
let mut tasks = batches.into_iter().fold(Vec::new(), |mut acc, batch| {
|
||||
acc.extend_from_slice(
|
||||
batch
|
||||
.trackers
|
||||
@ -148,18 +148,19 @@ pub async fn fetch_consumer_tasks(
|
||||
.map(|task| task.id.to_owned())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let updated_tasks = db
|
||||
.process_tracker_update_process_status_by_ids(
|
||||
task_ids,
|
||||
storage::ProcessTrackerUpdate::StatusUpdate {
|
||||
status: enums::ProcessTrackerStatus::ProcessStarted,
|
||||
business_status: None,
|
||||
},
|
||||
)
|
||||
.await
|
||||
.change_context(errors::ProcessTrackerError::ProcessFetchingFailed)?;
|
||||
|
||||
Ok(updated_tasks)
|
||||
db.process_tracker_update_process_status_by_ids(
|
||||
task_ids,
|
||||
storage::ProcessTrackerUpdate::StatusUpdate {
|
||||
status: enums::ProcessTrackerStatus::ProcessStarted,
|
||||
business_status: None,
|
||||
},
|
||||
)
|
||||
.await
|
||||
.change_context(errors::ProcessTrackerError::ProcessFetchingFailed)?;
|
||||
tasks
|
||||
.iter_mut()
|
||||
.for_each(|x| x.status = enums::ProcessTrackerStatus::ProcessStarted);
|
||||
Ok(tasks)
|
||||
}
|
||||
|
||||
// Accept flow_options if required
|
||||
|
||||
@ -49,7 +49,7 @@ pub async fn update_status_and_append(
|
||||
.collect();
|
||||
match flow {
|
||||
SchedulerFlow::Producer => {
|
||||
let res = state
|
||||
state
|
||||
.store
|
||||
.process_tracker_update_process_status_by_ids(
|
||||
process_ids,
|
||||
@ -58,18 +58,13 @@ pub async fn update_status_and_append(
|
||||
business_status: None,
|
||||
},
|
||||
)
|
||||
.await;
|
||||
match res {
|
||||
Ok(trackers) => {
|
||||
let count = trackers.len();
|
||||
logger::debug!("Updated status of {count} processes");
|
||||
Ok(())
|
||||
}
|
||||
Err(error) => {
|
||||
.await.map_or_else(|error| {
|
||||
logger::error!(error=%error.current_context(),"Error while updating process status");
|
||||
Err(error.change_context(errors::ProcessTrackerError::ProcessUpdateFailed))
|
||||
}
|
||||
}
|
||||
}, |count| {
|
||||
logger::debug!("Updated status of {count} processes");
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
SchedulerFlow::Cleaner => {
|
||||
let res = state
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
use error_stack::ResultExt;
|
||||
use serde::Serialize;
|
||||
pub use storage_models::process_tracker::{
|
||||
Milliseconds, ProcessData, ProcessTracker, ProcessTrackerNew, ProcessTrackerUpdate,
|
||||
ProcessData, ProcessTracker, ProcessTrackerNew, ProcessTrackerUpdate,
|
||||
ProcessTrackerUpdateInternal, SchedulerOptions,
|
||||
};
|
||||
use time::PrimitiveDateTime;
|
||||
|
||||
Reference in New Issue
Block a user