pub struct SocketFanOut { /* private fields */ }Expand description
Delivers relayed broadcasts to the sockets in a Rooms registry.
use std::sync::Arc;
use rainier_framework::relay::SocketFanOut;
use rainier_websocket::Rooms;
let rooms = Arc::new(Rooms::new());
// Channels are named `private-orders.7`; this application's rooms are
// named `orders.7`.
let fan_out = SocketFanOut::new(Arc::clone(&rooms))
.naming_rooms(|channel| Some(channel.trim_start_matches("private-").to_string()));Implementations§
Source§impl SocketFanOut
impl SocketFanOut
Sourcepub fn new(rooms: Arc<Rooms>) -> Self
pub fn new(rooms: Arc<Rooms>) -> Self
Deliver to rooms, with the room named exactly as the channel is.
Sourcepub fn naming_rooms<F>(self, room_for: F) -> Self
pub fn naming_rooms<F>(self, room_for: F) -> Self
Decide the room a channel’s broadcasts belong in.
None drops the broadcast, which is how a relay ignores channels this
process does not serve — a topic shared with another application, or a
channel that only a Pusher client listens to.
Sourcepub fn deliver(&self, broadcast: &RelayedBroadcast) -> usize
pub fn deliver(&self, broadcast: &RelayedBroadcast) -> usize
Send one broadcast to whoever is in the room. Returns how many got it.
to_others is honoured here, at the point of delivery, because this
is the only place that knows which sockets it is talking to. An identity
minted by another replica names no socket in this process, so nothing is
skipped and everyone here is told — which is the correct answer, not a
fallback.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SocketFanOut
impl !UnwindSafe for SocketFanOut
impl Freeze for SocketFanOut
impl Send for SocketFanOut
impl Sync for SocketFanOut
impl Unpin for SocketFanOut
impl UnsafeUnpin for SocketFanOut
Blanket Implementations§
impl<T> Actor for T
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Event for T
impl<T> Event for T
Source§fn event_name() -> &'static strwhere
Self: Sized,
fn event_name() -> &'static strwhere
Self: Sized,
A human-readable name, used by wildcard listeners and log output.
Always the Rust type path; see the trait docs.
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> ⓘ
Converts
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> ⓘ
Converts
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 moreCreates a shared type from an unshared type.