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
refactor(redis_interface): remove the `Drop` implementation on `RedisConnectionPool` (#1786)
Sanchith Hegdeac17b11e0911
diff --git a/crates/redis_interface/src/lib.rs b/crates/redis_interface/src/lib.rsindex b06cc6c274..3df54d5dc8 100644--- a/crates/redis_interface/src/lib.rs+++ b/crates/redis_interface/src/lib.rs@@ -33,7 +33,6 @@ pub use self::{commands::*, types::*};pub struct RedisConnectionPool {pub pool: fred::pool::RedisPool,config: RedisConfig,- join_handles: Vec<fred::types::ConnectHandle>,pub subscriber: SubscriberClient,pub publisher: RedisClient,pub is_redis_available: Arc<atomic::AtomicBool>,@@ -136,7 +135,6 @@ impl RedisConnectionPool {.into_report().change_context(errors::RedisError::RedisConnectionError)?;- let join_handles = pool.connect();pool.wait_for_connect().await.into_report()@@ -147,37 +145,12 @@ impl RedisConnectionPool {Ok(Self {pool,config,- join_handles,is_redis_available: Arc::new(atomic::AtomicBool::new(true)),subscriber,publisher,})}- pub async fn close_connections(&mut self) {- self.pool.quit_pool().await;-- self.publisher- .quit()- .await- .map_err(|err| logger::error!(redis_quit_err=?err))- .ok();-- self.subscriber- .quit()- .await- .map_err(|err| logger::error!(redis_quit_err=?err))- .ok();-- for handle in self.join_handles.drain(..) {- match handle.await {- Ok(Ok(_)) => (),- Ok(Err(error)) => logger::error!(%error),- Err(error) => logger::error!(%error),- };- }- }-pub async fn on_error(&self, tx: tokio::sync::oneshot::Sender<()>) {while let Ok(redis_error) = self.pool.on_error().recv().await {logger::error!(?redis_error, "Redis protocol or connection error");@@ -194,14 +167,6 @@ impl RedisConnectionPool {}}-impl Drop for RedisConnectionPool {- // safety: panics when invoked without a current tokio runtime- fn drop(&mut self) {- let rt = tokio::runtime::Handle::current();- rt.block_on(self.close_connections())- }-}-struct RedisConfig {default_ttl: u32,default_stream_read_count: u64,diff --git a/crates/router/src/connection.rs b/crates/router/src/connection.rsindex a84039a903..a5d436d0d8 100644--- a/crates/router/src/connection.rs+++ b/crates/router/src/connection.rs@@ -10,7 +10,6 @@ use crate::{configs::settings::Database, errors};pub type PgPool = bb8::Pool<async_bb8_diesel::ConnectionManager<PgConnection>>;pub type PgPooledConn = async_bb8_diesel::Connection<PgConnection>;-pub type RedisPool = std::sync::Arc<redis_interface::RedisConnectionPool>;#[derive(Debug)]struct TestTransaction;