mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 17:19:15 +08:00
fix: make drainer sleep on every loop interval instead of cycle end (#2951)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: preetamrevankar <132073736+preetamrevankar@users.noreply.github.com>
This commit is contained in:
@ -8,12 +8,13 @@ use redis_interface as redis;
|
||||
|
||||
use crate::{
|
||||
errors::{self, DrainerError},
|
||||
logger, metrics, services,
|
||||
logger, metrics, services, tracing,
|
||||
};
|
||||
|
||||
pub type StreamEntries = Vec<(String, HashMap<String, String>)>;
|
||||
pub type StreamReadResult = HashMap<String, StreamEntries>;
|
||||
|
||||
#[router_env::instrument(skip_all)]
|
||||
pub async fn is_stream_available(stream_index: u8, store: Arc<services::Store>) -> bool {
|
||||
let stream_key_flag = get_stream_key_flag(store.clone(), stream_index);
|
||||
|
||||
@ -132,10 +133,8 @@ pub fn parse_stream_entries<'a>(
|
||||
pub async fn increment_stream_index(
|
||||
(index, jobs_picked): (u8, Arc<atomic::AtomicU8>),
|
||||
total_streams: u8,
|
||||
interval: &mut tokio::time::Interval,
|
||||
) -> u8 {
|
||||
if index == total_streams - 1 {
|
||||
interval.tick().await;
|
||||
match jobs_picked.load(atomic::Ordering::SeqCst) {
|
||||
0 => metrics::CYCLES_COMPLETED_UNSUCCESSFULLY.add(&metrics::CONTEXT, 1, &[]),
|
||||
_ => metrics::CYCLES_COMPLETED_SUCCESSFULLY.add(&metrics::CONTEXT, 1, &[]),
|
||||
|
||||
Reference in New Issue
Block a user