pub struct RedisPubSubPublish { /* private fields */ }Expand description
The declaration half of the Pub/Sub publisher: delivery mode and envelope codec, no connection.
Constructible anywhere (in a router definition, in configuration), it pairs into a
RedisPubSubPublisher against a ConnectedRedisBroker. The publish mode must match how
subscribers subscribed: a sharded publish only reaches sharded subscribers.
§Examples
use ruststream_fred::stream::prelude::*;
use ruststream_fred::{PubSubMode, RedisPubSubPublish};
use serde::{Deserialize, Serialize};
#[derive(Deserialize)]
struct Order {
id: u64,
}
#[derive(Serialize, Outgoing)]
#[outgoing(name = "orders.live")]
struct Placed {
id: u64,
}
#[subscriber(RedisStream::new("orders").group("workers"), reply)]
async fn announce(order: &Order) -> Placed {
Placed { id: order.id }
}
#[ruststream::app]
fn app() -> impl App {
RustStream::new(AppInfo::new("orders", "0.1.0")).with_broker(
RedisBroker::cluster(["10.0.0.1:6379"]),
|b| {
// Read from a durable stream, broadcast to whoever is listening with `SPUBLISH`.
b.include(announce)
.out_reply(RedisPubSubPublish::new().mode(PubSubMode::Sharded));
},
)
}Implementations§
Source§impl RedisPubSubPublish
impl RedisPubSubPublish
Sourcepub fn new() -> Self
pub fn new() -> Self
A classic-mode policy with the default binary framing. Equivalent to Self::default.
Sourcepub const fn mode(self, mode: PubSubMode) -> Self
pub const fn mode(self, mode: PubSubMode) -> Self
Sets the publish mode. Defaults to PubSubMode::Classic.
Sourcepub fn codec(self, codec: impl Codec + 'static) -> Self
pub fn codec(self, codec: impl Codec + 'static) -> Self
Serializes the header/payload envelope with codec (must match the subscriber), which makes
the wire value readable while the data is text. Without it the default binary framing is
used. Either way a payload that is not text is published byte for byte.
Trait Implementations§
Source§impl Clone for RedisPubSubPublish
impl Clone for RedisPubSubPublish
Source§impl Debug for RedisPubSubPublish
impl Debug for RedisPubSubPublish
Source§impl Default for RedisPubSubPublish
impl Default for RedisPubSubPublish
Source§impl PublishPolicy<ConnectedRedisBroker> for RedisPubSubPublish
impl PublishPolicy<ConnectedRedisBroker> for RedisPubSubPublish
Source§fn channel_bindings(&self, channel: &str) -> Bindings
fn channel_bindings(&self, channel: &str) -> Bindings
The channel a PUBLISH goes out on, the delivery mode it goes out in, and how headers are
framed beside the payload.
Source§type Live = RedisPubSubPublisher
type Live = RedisPubSubPublisher
Publisher for a leaf policy, or the live
wiring form for a combinator stack (a typed publisher over a policy pairs into the same
typed publisher over the live leaf).Source§fn pair(
self,
connected: &ConnectedRedisBroker,
) -> impl Future<Output = Result<Self::Live, PairError>>
fn pair( self, connected: &ConnectedRedisBroker, ) -> impl Future<Output = Result<Self::Live, PairError>>
Source§fn operation_bindings(&self, channel: &str) -> Bindings
fn operation_bindings(&self, channel: &str) -> Bindings
send operation in the document. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for RedisPubSubPublish
impl !UnwindSafe for RedisPubSubPublish
impl Freeze for RedisPubSubPublish
impl Send for RedisPubSubPublish
impl Sync for RedisPubSubPublish
impl Unpin for RedisPubSubPublish
impl UnsafeUnpin for RedisPubSubPublish
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
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> 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