From 379b34bac2d385c6a0b464ae70ca1fd6e0ecda90 Mon Sep 17 00:00:00 2001 From: Jonas Platte <158304798+svix-jplatte@users.noreply.github.com> Date: Thu, 13 Jun 2024 18:50:33 +0200 Subject: [PATCH] redis: Use associated type bounds to simplify RedisConnection trait (#88) --- omniqueue/Cargo.toml | 2 +- omniqueue/src/backends/redis/mod.rs | 15 +++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/omniqueue/Cargo.toml b/omniqueue/Cargo.toml index 64a4203..2289c9d 100644 --- a/omniqueue/Cargo.toml +++ b/omniqueue/Cargo.toml @@ -6,7 +6,7 @@ description = "An abstraction layer over various queue backends" authors = ["Svix Inc. "] repository = "https://github.com/svix/omniqueue-rs/" readme = "../README.md" -rust-version = "1.75" +rust-version = "1.79" edition = "2021" [dependencies] diff --git a/omniqueue/src/backends/redis/mod.rs b/omniqueue/src/backends/redis/mod.rs index 22511c0..0a2ce7c 100644 --- a/omniqueue/src/backends/redis/mod.rs +++ b/omniqueue/src/backends/redis/mod.rs @@ -65,20 +65,14 @@ pub use cluster::RedisClusterConnectionManager; pub trait RedisConnection: ManageConnection< - Connection = ::Connection, - Error = ::Error, + Connection: redis::aio::ConnectionLike + Send + Sync, + Error: std::error::Error + Send + Sync + 'static, > { - type Connection: redis::aio::ConnectionLike + Send + Sync; - type Error: std::error::Error + Send + Sync + 'static; - fn from_dsn(dsn: &str) -> Result; } impl RedisConnection for RedisConnectionManager { - type Connection = ::Connection; - type Error = ::Error; - fn from_dsn(dsn: &str) -> Result { Self::new(dsn).map_err(QueueError::generic) } @@ -86,9 +80,6 @@ impl RedisConnection for RedisConnectionManager { #[cfg(feature = "redis_cluster")] impl RedisConnection for RedisClusterConnectionManager { - type Connection = ::Connection; - type Error = ::Error; - fn from_dsn(dsn: &str) -> Result { Self::new(dsn).map_err(QueueError::generic) } @@ -113,7 +104,7 @@ async fn check_eviction_policy( let results: Vec = redis::cmd("CONFIG") .arg("GET") .arg("maxmemory-policy") - .query_async::<::Connection, Vec>(&mut *conn) + .query_async::>(&mut *conn) .await .map_err(|_| EvictionCheckError::CheckEvictionPolicyFailed)?;