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§
sourcefn on_message<F>(&self, func: F) -> JoinHandle<RedisResult<()>>
fn on_message<F>(&self, func: F) -> JoinHandle<RedisResult<()>>
Spawn a task that runs the provided function on each publish-subscribe message.
See message_rx for more information.
sourcefn on_keyspace_event<F>(&self, func: F) -> JoinHandle<RedisResult<()>>
fn on_keyspace_event<F>(&self, func: F) -> JoinHandle<RedisResult<()>>
Spawn a task that runs the provided function on each keyspace event.
sourcefn on_reconnect<F>(&self, func: F) -> JoinHandle<RedisResult<()>>
fn on_reconnect<F>(&self, func: F) -> JoinHandle<RedisResult<()>>
Spawn a task that runs the provided function on each reconnection event.
Errors returned by func will exit the task.
sourcefn on_cluster_change<F>(&self, func: F) -> JoinHandle<RedisResult<()>>
fn on_cluster_change<F>(&self, func: F) -> JoinHandle<RedisResult<()>>
Spawn a task that runs the provided function on each cluster change event.
Errors returned by func will exit the task.
sourcefn on_error<F>(&self, func: F) -> JoinHandle<RedisResult<()>>
fn on_error<F>(&self, func: F) -> JoinHandle<RedisResult<()>>
Spawn a task that runs the provided function on each connection error event.
Errors returned by func will exit the task.
sourcefn on_unresponsive<F>(&self, func: F) -> JoinHandle<RedisResult<()>>
fn on_unresponsive<F>(&self, func: F) -> JoinHandle<RedisResult<()>>
Spawn a task that runs the provided function whenever the client detects an unresponsive connection.
sourcefn 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 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.
sourcefn message_rx(&self) -> BroadcastReceiver<Message>
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.
sourcefn keyspace_event_rx(&self) -> BroadcastReceiver<KeyspaceEvent>
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.
sourcefn reconnect_rx(&self) -> BroadcastReceiver<Server>
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.
sourcefn cluster_change_rx(&self) -> BroadcastReceiver<Vec<ClusterStateChange>>
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.
sourcefn error_rx(&self) -> BroadcastReceiver<RedisError>
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.
sourcefn unresponsive_rx(&self) -> BroadcastReceiver<Server>
fn unresponsive_rx(&self) -> BroadcastReceiver<Server>
Receive a message when the client initiates a reconnection after detecting an unresponsive connection.