Struct ntex_redis::SubscriptionClient
source · pub struct SubscriptionClient<U: Command + PubSubCommand> { /* private fields */ }
Expand description
Redis pubsub client to receive push messages
Implementations§
source§impl<U: Command + PubSubCommand> SubscriptionClient<U>
impl<U: Command + PubSubCommand> SubscriptionClient<U>
sourcepub fn into_client(self) -> SimpleClient
pub fn into_client(self) -> SimpleClient
Get client back. Don’t forget reset connection!
use ntex_redis::{cmd, RedisConnector};
#[ntex::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let redis = RedisConnector::new("127.0.0.1:6379").connect_simple().await?;
let subscriber = redis.subscribe(cmd::Subscribe(vec!["test"]))?;
// do some work
// go back to normal client
let redis = subscriber.into_client();
// and reset connection, client may receive pending subscription messages instead of valid RESET response
if let Err(e) = redis.exec(cmd::Reset()).await {
println!("Error on reset connection: {}", e);
};
Ok(())
}
sourcepub fn send<T: Command + PubSubCommand>(
&self,
cmd: T
) -> Result<(), CommandError>
pub fn send<T: Command + PubSubCommand>( &self, cmd: T ) -> Result<(), CommandError>
Send redis subscribe/unsubscribe command
Trait Implementations§
source§impl<U: Command + PubSubCommand> Stream for SubscriptionClient<U>
impl<U: Command + PubSubCommand> Stream for SubscriptionClient<U>
Auto Trait Implementations§
impl<U> !RefUnwindSafe for SubscriptionClient<U>
impl<U> !Send for SubscriptionClient<U>
impl<U> !Sync for SubscriptionClient<U>
impl<U> Unpin for SubscriptionClient<U>where U: Unpin,
impl<U> !UnwindSafe for SubscriptionClient<U>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more