pub struct RedisTransactionalPublish;Expand description
The stream publisher’s policy for a mount that publishes in transactions: it pairs into the same
RedisPublisher as RedisPublish, and only where the topology can run one.
Redis Cluster cannot run a MULTI / EXEC block across hash slots, so on a cluster this
policy refuses to pair and the service fails to start, naming the registration that asked for
it. Without the refusal a .transactional() batch reply would fail to open its transaction on
every batch and redeliver it without end.
§Examples
use ruststream_fred::stream::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize, Outgoing)]
#[outgoing(name = "orders.priced")]
struct Order {
id: u64,
}
#[subscriber(RedisStream::new("orders").group("workers"), reply)]
async fn price(orders: &[Order]) -> Result<Vec<Order>, HandlerOutcome> {
Ok(orders.iter().map(|order| Order { id: order.id }).collect())
}
#[ruststream::app]
fn app() -> impl App {
RustStream::new(AppInfo::new("orders", "0.1.0")).with_broker(
RedisBroker::standalone("redis://localhost:6379"),
|b| {
// `TransactionalPublish` is this policy under the stream prelude's name: one
// batch's replies land together, as one MULTI / EXEC block.
b.include(price.batch(nonzero!(32)))
.out_reply(TransactionalPublish)
.transactional();
},
)
}Trait Implementations§
Source§impl Clone for RedisTransactionalPublish
impl Clone for RedisTransactionalPublish
impl Copy for RedisTransactionalPublish
Source§impl Debug for RedisTransactionalPublish
impl Debug for RedisTransactionalPublish
Source§impl Default for RedisTransactionalPublish
impl Default for RedisTransactionalPublish
impl Eq for RedisTransactionalPublish
Source§impl PublishPolicy<ConnectedRedisBroker> for RedisTransactionalPublish
impl PublishPolicy<ConnectedRedisBroker> for RedisTransactionalPublish
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>>
§Errors
Returns a PairError carrying RedisError::InvalidOptions on a cluster topology.
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 channel_bindings(&self, channel: &str) -> Bindings
fn channel_bindings(&self, channel: &str) -> Bindings
What a publish through this policy adds to its channel in the generated
AsyncAPI
document. Read moreSource§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 RedisTransactionalPublish
Auto Trait Implementations§
impl Freeze for RedisTransactionalPublish
impl RefUnwindSafe for RedisTransactionalPublish
impl Send for RedisTransactionalPublish
impl Sync for RedisTransactionalPublish
impl Unpin for RedisTransactionalPublish
impl UnsafeUnpin for RedisTransactionalPublish
impl UnwindSafe for RedisTransactionalPublish
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