Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix: replace xtrim with xdel to support older redis version (#8515)
akshay-973d085abf3853
diff --git a/crates/drainer/src/handler.rs b/crates/drainer/src/handler.rsindex 74984b03fb..b832c02f1b 100644--- a/crates/drainer/src/handler.rs+++ b/crates/drainer/src/handler.rs@@ -277,9 +277,15 @@ async fn drainer(_ => break,},}++ if store.use_legacy_version() {+ store+ .delete_from_stream(stream_name, &last_processed_id)+ .await?;+ }}- if !last_processed_id.is_empty() {+ if !(last_processed_id.is_empty() || store.use_legacy_version()) {let entries_trimmed = store.trim_from_stream(stream_name, &last_processed_id).await?;diff --git a/crates/drainer/src/metrics.rs b/crates/drainer/src/metrics.rsindex 13fb31f7c5..c1f30bc408 100644--- a/crates/drainer/src/metrics.rs+++ b/crates/drainer/src/metrics.rs@@ -18,3 +18,4 @@ histogram_metric_f64!(REDIS_STREAM_READ_TIME, DRAINER_METER); // Time in (ms) mihistogram_metric_f64!(REDIS_STREAM_TRIM_TIME, DRAINER_METER); // Time in (ms) millisecondshistogram_metric_f64!(CLEANUP_TIME, DRAINER_METER); // Time in (ms) millisecondshistogram_metric_u64!(DRAINER_DELAY_SECONDS, DRAINER_METER); // Time in (s) seconds+histogram_metric_f64!(REDIS_STREAM_DEL_TIME, DRAINER_METER); // Time in (ms) millisecondsdiff --git a/crates/drainer/src/services.rs b/crates/drainer/src/services.rsindex 87057ebeff..14bef1bf23 100644--- a/crates/drainer/src/services.rs+++ b/crates/drainer/src/services.rs@@ -22,6 +22,7 @@ pub struct Store {pub struct StoreConfig {pub drainer_stream_name: String,pub drainer_num_partitions: u8,+ pub use_legacy_version: bool,}impl Store {@@ -45,10 +46,15 @@ impl Store {config: StoreConfig {drainer_stream_name: config.drainer.stream_name.clone(),drainer_num_partitions: config.drainer.num_partitions,+ use_legacy_version: config.redis.use_legacy_version,},request_id: None,}}++ pub fn use_legacy_version(&self) -> bool {+ self.config.use_legacy_version+ }}pub fn log_and_return_error_response<T>(error: Report<T>) -> HttpResponsediff --git a/crates/drainer/src/stream.rs b/crates/drainer/src/stream.rsindex 9e092b038e..8939aa5527 100644--- a/crates/drainer/src/stream.rs+++ b/crates/drainer/src/stream.rs@@ -110,4 +110,27 @@ impl Store {// adding 1 because we are deleting the given id tooOk(trim_result? + 1)}++ pub async fn delete_from_stream(+ &self,+ stream_name: &str,+ entry_id: &str,+ ) -> errors::DrainerResult<()> {+ let (_trim_result, execution_time) =+ common_utils::date_time::time_it::<errors::DrainerResult<_>, _, _>(|| async {+ self.redis_conn+ .stream_delete_entries(&stream_name.into(), entry_id)+ .await+ .map_err(errors::DrainerError::from)?;+ Ok(())+ })+ .await;++ metrics::REDIS_STREAM_DEL_TIME.record(+ execution_time,+ router_env::metric_attributes!(("stream", stream_name.to_owned())),+ );++ Ok(())+ }}