[][src]Struct iredismodule::block_client::BlockClient

#[repr(C)]pub struct BlockClient { /* fields omitted */ }

Wrap the pointer of a RedisModuleBlockedClient

Implementations

impl BlockClient[src]

pub fn unblock<T>(&self, privdata: Option<T>) -> Result<(), Error>[src]

Unblock a client blocked.

This will trigger the reply callbacks to be called in order to reply to the client.The 'privdata' argument will be accessible by the reply callback, so the caller of this function can pass any value that is needed in order to actually reply to the client.

A common usage for 'privdata' is a thread that computes something that needs to be passed to the client, included but not limited some slow to compute reply or some reply obtained via networking.

Note 1: this function can be called from threads spawned by the module.

Note 2: when we unblock a client that is blocked for keys using the API Context::block_client_on_keys, the privdata argument here is not used, and the reply callback is called with the privdata pointer that was passed when blocking the client.

Unblocking a client that was blocked for keys using this API will still require the client to get some reply, so the function will use the "timeout" handler in order to do so.

pub fn abort(&self) -> Result<(), Error>[src]

Abort a blocked client blocking operation: the client will be unblocked without firing any callback.

pub fn set_disconnect_callback(
    &self,
    callback: unsafe extern "C" fn(_: *mut RedisModuleCtx, _: *mut RedisModuleBlockedClient)
)
[src]

Set a callback that will be called if a blocked client disconnects before the module has a chance to call BlockClient::unblock

Usually what you want to do there, is to cleanup your module state so that you can call BlockClient::unblock safely, otherwise the client will remain blocked forever if the timeout is large.

Notes:

  1. It is not safe to call Reply* family functions here, it is also useless since the client is gone.

  2. This callback is not called if the client disconnects because of a timeout. In such a case, the client is unblocked automatically and the timeout callback is called.

pub fn get_threadsafe_context(&self) -> ThreadSafeContext[src]

Return a context which can be used inside threads to make Redis context calls with certain modules APIs.

Trait Implementations

impl Clone for BlockClient[src]

impl Copy for BlockClient[src]

impl FromPtr for BlockClient[src]

impl GetPtr for BlockClient[src]

impl Send for BlockClient[src]

impl Sync for BlockClient[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.