pub struct CustomRedisAdapter<E, R> { /* private fields */ }
Expand description
The redis adapter implementation.
It is generic over the Driver
used to communicate with the redis server.
And over the SocketEmitter
used to communicate with the local server. This allows to
avoid cyclic dependencies between the adapter, socketioxide-core
and socketioxide
crates.
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>
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>
Source§fn new(state: &Self::State, local: CoreLocalAdapter<E>) -> Self
fn new(state: &Self::State, local: CoreLocalAdapter<E>) -> Self
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
Source§async fn disconnect_socket(
&self,
opts: BroadcastOptions,
) -> Result<(), BroadcastError>
async fn disconnect_socket( &self, opts: BroadcastOptions, ) -> Result<(), BroadcastError>
BroadcastOptions
.Source§async fn rooms(&self, opts: BroadcastOptions) -> Result<Vec<Room>, Self::Error>
async fn rooms(&self, opts: BroadcastOptions) -> Result<Vec<Room>, Self::Error>
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>
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>
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>
BroadcastOptions
.Source§fn get_local(&self) -> &CoreLocalAdapter<E>
fn get_local(&self) -> &CoreLocalAdapter<E>
impl<E, R> DefinedAdapter for CustomRedisAdapter<E, R>
Auto Trait Implementations§
impl<E, R> !Freeze for CustomRedisAdapter<E, R>
impl<E, R> RefUnwindSafe for CustomRedisAdapter<E, R>where
R: RefUnwindSafe,
E: RefUnwindSafe,
impl<E, R> Send for CustomRedisAdapter<E, R>
impl<E, R> Sync for CustomRedisAdapter<E, R>
impl<E, R> Unpin for CustomRedisAdapter<E, R>
impl<E, R> UnwindSafe for CustomRedisAdapter<E, R>where
R: UnwindSafe,
E: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more