use super::pool::RedisPool;
use crate::utils::error::gateway_error::{GatewayError, Result};
use redis::AsyncCommands;
pub struct Subscription {
_placeholder: (),
}
impl RedisPool {
pub async fn publish(&self, channel: &str, message: &str) -> Result<()> {
if self.noop_mode {
return Ok(());
}
let mut conn = self.get_connection().await?;
if let Some(ref mut c) = conn.conn {
let _: () = c
.publish(channel, message)
.await
.map_err(GatewayError::from)?;
}
Ok(())
}
pub async fn subscribe(&self, _channels: &[String]) -> Result<Subscription> {
Err(GatewayError::Storage(
"PubSub subscribe is not yet implemented".to_string(),
))
}
}
impl Subscription {
pub async fn next_message(&mut self) -> Result<redis::Msg> {
Err(GatewayError::Storage(
"PubSub subscribe is not yet implemented".to_string(),
))
}
pub async fn unsubscribe_all(&mut self) -> Result<()> {
Ok(())
}
}