[−][src]Struct iredismodule::block_client::BlockClient
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]
&self,
callback: unsafe extern "C" fn(_: *mut RedisModuleCtx, _: *mut RedisModuleBlockedClient)
)
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:
-
It is not safe to call Reply* family functions here, it is also useless since the client is gone.
-
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]
fn clone(&self) -> BlockClient
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for BlockClient
[src]
impl FromPtr for BlockClient
[src]
type PtrType = RedisModuleBlockedClient
fn from_ptr(ptr: *mut RedisModuleBlockedClient) -> 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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,