diff --git a/deepwell/src/endpoints/misc.rs b/deepwell/src/endpoints/misc.rs index c23d0a10dd..4999b31c44 100644 --- a/deepwell/src/endpoints/misc.rs +++ b/deepwell/src/endpoints/misc.rs @@ -37,15 +37,14 @@ async fn postgres_check(ctx: &ServiceContext<'_>) -> Result<()> { } async fn redis_check(ctx: &ServiceContext<'_>) -> Result<()> { - /* - ctx.redis() + let mut redis = ctx.redis_connect().await?; + + redis .send_packed_command(redis::Cmd::new().arg("PING")) .await?; debug!("Successfully pinged Redis"); Ok(()) - */ - todo!() } pub async fn ping( diff --git a/deepwell/src/services/context.rs b/deepwell/src/services/context.rs index d44b51bbb1..9074c64e0d 100644 --- a/deepwell/src/services/context.rs +++ b/deepwell/src/services/context.rs @@ -22,7 +22,8 @@ use crate::api::ServerState; use crate::config::Config; use crate::locales::Localizations; use crate::services::blob::MimeAnalyzer; -use redis::aio::ConnectionManager; +use crate::services::error::Result; +use redis::aio::MultiplexedConnection as RedisMultiplexedConnection; use rsmq_async::PooledRsmq; use s3::bucket::Bucket; use sea_orm::DatabaseTransaction; @@ -53,10 +54,19 @@ impl<'txn> ServiceContext<'txn> { } #[inline] - pub fn redis(&self) -> &redis::Client { + pub fn redis_client(&self) -> &redis::Client { &self.state.redis } + pub async fn redis_connect(&self) -> Result { + let conn = self + .redis_client() + .get_multiplexed_tokio_connection() + .await?; + + Ok(conn) + } + #[inline] pub fn rsmq(&self) -> PooledRsmq { PooledRsmq::clone(&self.state.rsmq)