pub struct SubscriptionClient<U: Command + PubSubCommand> { /* private fields */ }
Expand description

Redis pubsub client to receive push messages

Implementations§

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(())
}

Send redis subscribe/unsubscribe command

Attempt to pull out the next value of this stream.

Attempt to pull out the next value of this stream, registering the current task for wakeup if the value is not yet available, and returning None if the payload is exhausted.

Trait Implementations§

Values yielded by the stream.
Attempt to pull out the next value of this stream, registering the current task for wakeup if the value is not yet available, and returning None if the stream is exhausted. Read more
Returns the bounds on the remaining length of the stream. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
The type of successful values yielded by this future
The type of failures yielded by this future
Poll this TryStream as if it were a Stream. Read more