pub struct RedisPublish;Expand description
The declaration half of the stream publisher: pure policy, constructible anywhere.
XADD needs no options beyond the target key, which travels on each message, so the policy is
a unit marker. It pairs into a RedisPublisher against a ConnectedRedisBroker, which is
what makes “publishing before connect” unrepresentable.
§Examples
use ruststream_fred::stream::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Deserialize)]
struct Order {
id: u64,
}
#[derive(Serialize, Outgoing)]
#[outgoing(name = "orders.accepted")]
struct Accepted {
id: u64,
}
#[subscriber(RedisStream::new("orders").group("workers"), reply)]
async fn accept(order: &Order) -> Accepted {
Accepted { id: order.id }
}
#[ruststream::app]
fn app() -> impl App {
RustStream::new(AppInfo::new("orders", "0.1.0")).with_broker(
RedisBroker::standalone("redis://localhost:6379"),
|b| {
// `Publish` is this policy under the stream prelude's name. No connection exists
// yet; the runtime pairs it with the connected broker at startup.
b.include(accept).out_reply(Publish);
},
)
}Trait Implementations§
Source§impl Clone for RedisPublish
impl Clone for RedisPublish
impl Copy for RedisPublish
Source§impl Debug for RedisPublish
impl Debug for RedisPublish
Source§impl Default for RedisPublish
impl Default for RedisPublish
impl Eq for RedisPublish
Source§impl PartialEq for RedisPublish
impl PartialEq for RedisPublish
Source§impl PublishPolicy<ConnectedRedisBroker> for RedisPublish
impl PublishPolicy<ConnectedRedisBroker> for RedisPublish
Source§fn channel_bindings(&self, channel: &str) -> Bindings
fn channel_bindings(&self, channel: &str) -> Bindings
An XADD carries its headers as entry fields and the policy has no settings of its own, so
what the document learns from here is which Redis structure the channel is and which stream
key the entries are appended to.
Source§type Live = RedisPublisher
type Live = RedisPublisher
The live form this policy pairs into: a
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>>
Pairs the policy with a connected broker, producing the live publisher. Read more
Source§fn operation_bindings(&self, channel: &str) -> Bindings
fn operation_bindings(&self, channel: &str) -> Bindings
What a publish through this policy adds to its
send operation in the document. Read moreimpl StructuralPartialEq for RedisPublish
Auto Trait Implementations§
impl Freeze for RedisPublish
impl RefUnwindSafe for RedisPublish
impl Send for RedisPublish
impl Sync for RedisPublish
impl Unpin for RedisPublish
impl UnsafeUnpin for RedisPublish
impl UnwindSafe for RedisPublish
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
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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 more