fix(drainer): ignore errors in case the stream is empty (#2261)

Co-authored-by: Arun Raj M <jarnura47@gmail.com>
This commit is contained in:
Kartikeya Hegde
2023-09-25 14:49:42 +05:30
committed by GitHub
parent e4af3812d5
commit 53de86f60d
5 changed files with 30 additions and 6 deletions

View File

@ -16,6 +16,7 @@ use common_utils::{
use error_stack::{IntoReport, ResultExt};
use fred::{
interfaces::{HashesInterface, KeysInterface, StreamsInterface},
prelude::RedisErrorKind,
types::{
Expiration, FromRedis, MultipleIDs, MultipleKeys, MultipleOrderedPairs, MultipleStrings,
RedisKey, RedisMap, RedisValue, Scanner, SetOptions, XCap, XReadResponse,
@ -539,7 +540,12 @@ impl super::RedisConnectionPool {
)
.await
.into_report()
.change_context(errors::RedisError::StreamReadFailed)
.map_err(|err| match err.current_context().kind() {
RedisErrorKind::NotFound => {
err.change_context(errors::RedisError::StreamEmptyOrNotAvailable)
}
_ => err.change_context(errors::RedisError::StreamReadFailed),
})
}
#[instrument(level = "DEBUG", skip(self))]