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:
Kartikeya Hegde
2023-11-23 18:29:14 +05:30
committed by GitHub
parent dd3e22a938
commit e8df69092f
4 changed files with 6 additions and 6 deletions

View File

@ -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, &[]),