diff options
| author | rtkay123 <dev@kanjala.com> | 2026-04-06 20:06:14 +0200 |
|---|---|---|
| committer | rtkay123 <dev@kanjala.com> | 2026-04-06 20:06:14 +0200 |
| commit | cf51cf6f7424a85795bc67b3cece29c806a6d7e0 (patch) | |
| tree | 115a76de126dabf2c912715ef898f482d1bb992b /crates/sh-util/src/cache/sentinel.rs | |
| parent | d575e966a422ea87508ef5370b2904f4818c6773 (diff) | |
| download | sellershut-cf51cf6f7424a85795bc67b3cece29c806a6d7e0.tar.bz2 sellershut-cf51cf6f7424a85795bc67b3cece29c806a6d7e0.zip | |
feat(oauth): redirect
Diffstat (limited to 'crates/sh-util/src/cache/sentinel.rs')
| -rw-r--r-- | crates/sh-util/src/cache/sentinel.rs | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/crates/sh-util/src/cache/sentinel.rs b/crates/sh-util/src/cache/sentinel.rs index e52b043..5406c4d 100644 --- a/crates/sh-util/src/cache/sentinel.rs +++ b/crates/sh-util/src/cache/sentinel.rs @@ -1,12 +1,3 @@ -use futures_util::lock::Mutex; -use redis::{ - ErrorKind, IntoConnectionInfo, RedisError, - sentinel::{SentinelClient, SentinelNodeConnectionInfo, SentinelServerType}, -}; -use serde::Deserialize; - -struct LockedSentinelClient(pub(crate) Mutex<SentinelClient>); - #[derive(Clone, Debug, Eq, PartialEq)] pub struct SentinelConfig { pub service_name: String, @@ -16,51 +7,3 @@ pub struct SentinelConfig { pub redis_password: String, pub redis_use_resp3: bool, } - -/// ConnectionManager that implements `bb8::ManageConnection` and supports -/// asynchronous Sentinel connections via `redis::sentinel::SentinelClient` -pub struct RedisSentinelConnectionManager { - client: LockedSentinelClient, -} - -impl RedisSentinelConnectionManager { - pub fn new<T: IntoConnectionInfo>( - info: Vec<T>, - service_name: String, - node_connection_info: Option<SentinelNodeConnectionInfo>, - ) -> Result<RedisSentinelConnectionManager, RedisError> { - Ok(RedisSentinelConnectionManager { - client: LockedSentinelClient(Mutex::new(SentinelClient::build( - info, - service_name, - node_connection_info, - SentinelServerType::Master, - )?)), - }) - } -} - -impl bb8::ManageConnection for RedisSentinelConnectionManager { - type Connection = redis::aio::MultiplexedConnection; - type Error = RedisError; - - async fn connect(&self) -> Result<Self::Connection, Self::Error> { - self.client.0.lock().await.get_async_connection().await - } - - async fn is_valid(&self, conn: &mut Self::Connection) -> Result<(), Self::Error> { - let pong: String = redis::cmd("PING").query_async(conn).await?; - match pong.as_str() { - "PONG" => Ok(()), - _ => Err(( - ErrorKind::Server(redis::ServerErrorKind::ResponseError), - "ping request", - ) - .into()), - } - } - - fn has_broken(&self, _: &mut Self::Connection) -> bool { - false - } -} |
