pub type ClusterAdapter<E> = CustomRedisAdapter<E, ClusterDriver>;
Available on crate feature
redis-cluster
only.Expand description
The redis adapter with the redis cluster driver.
Aliased Type§
pub struct ClusterAdapter<E> { /* private fields */ }
Trait Implementations
Source§impl<E: SocketEmitter, R: Driver> CoreAdapter<E> for CustomRedisAdapter<E, R>
impl<E: SocketEmitter, R: Driver> CoreAdapter<E> for CustomRedisAdapter<E, R>
Source§async fn server_count(&self) -> Result<u16, Self::Error>
async fn server_count(&self) -> Result<u16, Self::Error>
Get the number of servers by getting the number of subscribers to the request channel.
Source§async fn broadcast(
&self,
packet: Packet,
opts: BroadcastOptions,
) -> Result<(), BroadcastError>
async fn broadcast( &self, packet: Packet, opts: BroadcastOptions, ) -> Result<(), BroadcastError>
Broadcast a packet to all the servers to send them through their sockets.
Source§async fn broadcast_with_ack(
&self,
packet: Packet,
opts: BroadcastOptions,
timeout: Option<Duration>,
) -> Result<Self::AckStream, Self::Error>
async fn broadcast_with_ack( &self, packet: Packet, opts: BroadcastOptions, timeout: Option<Duration>, ) -> Result<Self::AckStream, Self::Error>
Broadcast a packet to all the servers to send them through their sockets.
Returns a Stream that is a combination of the local ack stream and a remote MessageStream
.
Here is a specific protocol in order to know how many message the server expect to close
the stream at the right time:
- Get the number
n
of remote servers. - Send the broadcast request.
- Expect
n
BroadcastAckCount
response in the stream to know the numberm
of expected ack responses. - Expect
sum(m)
broadcast counts sent by the servers.
Example with 3 remote servers (n = 3):
+---+ +---+ +---+
| A | | B | | C |
+---+ +---+ +---+
| | |
|---BroadcastWithAck--->| |
|---BroadcastWithAck--------------------------->|
| | |
|<-BroadcastAckCount(2)-| (n = 2; m = 2) |
|<-BroadcastAckCount(2)-------(n = 2; m = 4)----|
| | |
|<----------------Ack---------------------------|
|<----------------Ack---| |
| | |
|<----------------Ack---------------------------|
|<----------------Ack---| |
Source§type State = RedisAdapterCtr<R>
type State = RedisAdapterCtr<R>
A shared state between all the namespace
CoreAdapter
.
This can be used to share a connection for example.Source§type AckStream = AckStream<<E as SocketEmitter>::AckStream>
type AckStream = AckStream<<E as SocketEmitter>::AckStream>
A stream that emits the acknowledgments of multiple sockets.
Source§fn new(state: &Self::State, local: CoreLocalAdapter<E>) -> Self
fn new(state: &Self::State, local: CoreLocalAdapter<E>) -> Self
Creates a new adapter with the given state and local adapter. Read more
Source§fn init(
self: Arc<Self>,
on_success: impl FnOnce() + Send + 'static,
) -> Self::InitRes
fn init( self: Arc<Self>, on_success: impl FnOnce() + Send + 'static, ) -> Self::InitRes
Initializes the adapter. The on_success callback should be called when the adapter ready.
Source§async fn disconnect_socket(
&self,
opts: BroadcastOptions,
) -> Result<(), BroadcastError>
async fn disconnect_socket( &self, opts: BroadcastOptions, ) -> Result<(), BroadcastError>
Disconnects the sockets that match the
BroadcastOptions
.Source§async fn rooms(&self, opts: BroadcastOptions) -> Result<Vec<Room>, Self::Error>
async fn rooms(&self, opts: BroadcastOptions) -> Result<Vec<Room>, Self::Error>
Fetches rooms that match the
BroadcastOptions
Source§async fn add_sockets(
&self,
opts: BroadcastOptions,
rooms: impl RoomParam,
) -> Result<(), Self::Error>
async fn add_sockets( &self, opts: BroadcastOptions, rooms: impl RoomParam, ) -> Result<(), Self::Error>
Adds the sockets that match the
BroadcastOptions
to the rooms.Source§async fn del_sockets(
&self,
opts: BroadcastOptions,
rooms: impl RoomParam,
) -> Result<(), Self::Error>
async fn del_sockets( &self, opts: BroadcastOptions, rooms: impl RoomParam, ) -> Result<(), Self::Error>
Removes the sockets that match the
BroadcastOptions
from the rooms.Source§async fn fetch_sockets(
&self,
opts: BroadcastOptions,
) -> Result<Vec<RemoteSocketData>, Self::Error>
async fn fetch_sockets( &self, opts: BroadcastOptions, ) -> Result<Vec<RemoteSocketData>, Self::Error>
Fetches remote sockets that match the
BroadcastOptions
.Source§fn get_local(&self) -> &CoreLocalAdapter<E>
fn get_local(&self) -> &CoreLocalAdapter<E>
Returns the local adapter. Used to enable default behaviors.