feat(multitenancy): add support for multitenancy and handle the same in router, producer, consumer, drainer and analytics (#4630)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: Arun Raj M <jarnura47@gmail.com>
This commit is contained in:
Jagan
2024-06-03 17:57:30 +05:30
committed by GitHub
parent a1788b8da9
commit 15d6c3e846
188 changed files with 2260 additions and 1414 deletions

View File

@ -1,7 +1,4 @@
use std::{
sync::{self, atomic},
time as std_time,
};
use std::sync;
use common_utils::errors::CustomResult;
use diesel_models::enums::{self, ProcessTrackerStatus};
@ -17,7 +14,7 @@ use super::{
};
use crate::{
configs::settings::SchedulerSettings, consumer::types::ProcessTrackerBatch, errors,
flow::SchedulerFlow, metrics, SchedulerAppState, SchedulerInterface,
flow::SchedulerFlow, metrics, SchedulerInterface, SchedulerSessionState,
};
pub async fn divide_and_append_tasks<T>(
@ -258,26 +255,16 @@ pub async fn consumer_operation_handler<E, T>(
state: T,
settings: sync::Arc<SchedulerSettings>,
error_handler_fun: E,
consumer_operation_counter: sync::Arc<atomic::AtomicU64>,
workflow_selector: impl workflows::ProcessTrackerWorkflows<T> + 'static + Copy + std::fmt::Debug,
) where
// Error handler function
E: FnOnce(error_stack::Report<errors::ProcessTrackerError>),
T: SchedulerAppState + Send + Sync + 'static,
T: SchedulerSessionState + Send + Sync + 'static,
{
consumer_operation_counter.fetch_add(1, atomic::Ordering::SeqCst);
let start_time = std_time::Instant::now();
match consumer::consumer_operations(&state, &settings, workflow_selector).await {
Ok(_) => (),
Err(err) => error_handler_fun(err),
}
let end_time = std_time::Instant::now();
let duration = end_time.saturating_duration_since(start_time).as_secs_f64();
logger::debug!("Time taken to execute consumer_operation: {}s", duration);
let current_count = consumer_operation_counter.fetch_sub(1, atomic::Ordering::SeqCst);
logger::info!("Current tasks being executed: {}", current_count);
}
pub fn add_histogram_metrics(