Trait fred::interfaces::EventInterface

source ·
pub trait EventInterface: ClientLike {
Show 13 methods // Provided methods fn on_message<F>(&self, func: F) -> JoinHandle<RedisResult<()>> where F: Fn(Message) -> RedisResult<()> + 'static { ... } fn on_keyspace_event<F>(&self, func: F) -> JoinHandle<RedisResult<()>> where F: Fn(KeyspaceEvent) -> RedisResult<()> + 'static { ... } fn on_reconnect<F>(&self, func: F) -> JoinHandle<RedisResult<()>> where F: Fn(Server) -> RedisResult<()> + 'static { ... } fn on_cluster_change<F>(&self, func: F) -> JoinHandle<RedisResult<()>> where F: Fn(Vec<ClusterStateChange>) -> RedisResult<()> + 'static { ... } fn on_error<F>(&self, func: F) -> JoinHandle<RedisResult<()>> where F: Fn(RedisError) -> RedisResult<()> + 'static { ... } fn on_unresponsive<F>(&self, func: F) -> JoinHandle<RedisResult<()>> where F: Fn(Server) -> RedisResult<()> + 'static { ... } fn on_any<Fe, Fr, Fc>( &self, error_fn: Fe, reconnect_fn: Fr, cluster_change_fn: Fc, ) -> JoinHandle<RedisResult<()>> where Fe: Fn(RedisError) -> RedisResult<()> + 'static, Fr: Fn(Server) -> RedisResult<()> + 'static, Fc: Fn(Vec<ClusterStateChange>) -> RedisResult<()> + 'static { ... } fn message_rx(&self) -> BroadcastReceiver<Message> { ... } fn keyspace_event_rx(&self) -> BroadcastReceiver<KeyspaceEvent> { ... } fn reconnect_rx(&self) -> BroadcastReceiver<Server> { ... } fn cluster_change_rx(&self) -> BroadcastReceiver<Vec<ClusterStateChange>> { ... } fn error_rx(&self) -> BroadcastReceiver<RedisError> { ... } fn unresponsive_rx(&self) -> BroadcastReceiver<Server> { ... }
}
Expand description

An interface that exposes various client and connection events.

Calling quit will close all event streams.

Provided Methods§

source

fn on_message<F>(&self, func: F) -> JoinHandle<RedisResult<()>>
where F: Fn(Message) -> RedisResult<()> + 'static,

Spawn a task that runs the provided function on each publish-subscribe message.

See message_rx for more information.

source

fn on_keyspace_event<F>(&self, func: F) -> JoinHandle<RedisResult<()>>
where F: Fn(KeyspaceEvent) -> RedisResult<()> + 'static,

Spawn a task that runs the provided function on each keyspace event.

https://redis.io/topics/notifications

source

fn on_reconnect<F>(&self, func: F) -> JoinHandle<RedisResult<()>>
where F: Fn(Server) -> RedisResult<()> + 'static,

Spawn a task that runs the provided function on each reconnection event.

Errors returned by func will exit the task.

source

fn on_cluster_change<F>(&self, func: F) -> JoinHandle<RedisResult<()>>
where F: Fn(Vec<ClusterStateChange>) -> RedisResult<()> + 'static,

Spawn a task that runs the provided function on each cluster change event.

Errors returned by func will exit the task.

source

fn on_error<F>(&self, func: F) -> JoinHandle<RedisResult<()>>
where F: Fn(RedisError) -> RedisResult<()> + 'static,

Spawn a task that runs the provided function on each connection error event.

Errors returned by func will exit the task.

source

fn on_unresponsive<F>(&self, func: F) -> JoinHandle<RedisResult<()>>
where F: Fn(Server) -> RedisResult<()> + 'static,

Spawn a task that runs the provided function whenever the client detects an unresponsive connection.

source

fn on_any<Fe, Fr, Fc>( &self, error_fn: Fe, reconnect_fn: Fr, cluster_change_fn: Fc, ) -> JoinHandle<RedisResult<()>>
where Fe: Fn(RedisError) -> RedisResult<()> + 'static, Fr: Fn(Server) -> RedisResult<()> + 'static, Fc: Fn(Vec<ClusterStateChange>) -> RedisResult<()> + 'static,

Spawn one task that listens for all connection management event types.

Errors in any of the provided functions will exit the task.

source

fn message_rx(&self) -> BroadcastReceiver<Message>

Listen for messages on the publish-subscribe interface.

Keyspace events are not sent on this interface.

If the connection to the Redis server closes for any reason this function does not need to be called again. Messages will start appearing on the original stream after subscribe is called again.

source

fn keyspace_event_rx(&self) -> BroadcastReceiver<KeyspaceEvent>

Listen for keyspace and keyevent notifications on the publish-subscribe interface.

Callers still need to configure the server and subscribe to the relevant channels, but this interface will parse and format the messages automatically.

https://redis.io/topics/notifications

source

fn reconnect_rx(&self) -> BroadcastReceiver<Server>

Listen for reconnection notifications.

This function can be used to receive notifications whenever the client reconnects in order to re-subscribe to channels, etc.

A reconnection event is also triggered upon first connecting to the server.

source

fn cluster_change_rx(&self) -> BroadcastReceiver<Vec<ClusterStateChange>>

Listen for notifications whenever the cluster state changes.

This is usually triggered in response to a MOVED error, but can also happen when connections close unexpectedly.

source

fn error_rx(&self) -> BroadcastReceiver<RedisError>

Listen for protocol and connection errors. This stream can be used to more intelligently handle errors that may not appear in the request-response cycle, and so cannot be handled by response futures.

source

fn unresponsive_rx(&self) -> BroadcastReceiver<Server>

Receive a message when the client initiates a reconnection after detecting an unresponsive connection.

Object Safety§

This trait is not object safe.

Implementors§