pub struct RedisPublisher { /* private fields */ }Expand description
Redis publisher built on a shared fred connection pool. Cheap to clone.
Holds the broker’s shared connection cell, so a publisher created before the broker connects
resolves the pool on first use; publishing before
Broker::connect returns RedisError::NotConnected.
Publisher::publish appends the message to the stream named by
OutgoingMessage::name with XADD <name> * .... The
payload and headers are encoded as entry fields (see crate::RedisStream for the consuming
side).
§Transactions
On standalone and sentinel topologies the publisher implements TransactionalPublisher:
begin_transaction starts buffering published
messages, commit flushes the buffer in publish order through
a single fred pipeline, and abort discards it. Cluster does
not support it (buffered keys may live on different nodes), so begin_transaction returns
RedisError::InvalidOptions there. Clones of a handle share the same open transaction buffer.
Trait Implementations§
Source§impl Clone for RedisPublisher
impl Clone for RedisPublisher
Source§fn clone(&self) -> RedisPublisher
fn clone(&self) -> RedisPublisher
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RedisPublisher
impl Debug for RedisPublisher
Source§impl Publisher for RedisPublisher
impl Publisher for RedisPublisher
Source§impl TransactionalPublisher for RedisPublisher
impl TransactionalPublisher for RedisPublisher
Source§async fn begin_transaction(&self) -> Result<(), Self::Error>
async fn begin_transaction(&self) -> Result<(), Self::Error>
Starts buffering. A no-op if a transaction is already open (it continues).
§Errors
Returns RedisError::InvalidOptions on a cluster topology, which cannot offer
multi-key transactions.
Source§async fn commit(&self) -> Result<(), Self::Error>
async fn commit(&self) -> Result<(), Self::Error>
Flushes the buffered XADDs in publish order through one pipeline, then clears the
transaction. A commit with no open transaction is a no-op.
§Errors
Returns RedisError::NotConnected if the broker never connected, or
RedisError::Publish if the pipeline fails. On failure the buffer is already cleared.
Auto Trait Implementations§
impl !RefUnwindSafe for RedisPublisher
impl !UnwindSafe for RedisPublisher
impl Freeze for RedisPublisher
impl Send for RedisPublisher
impl Sync for RedisPublisher
impl Unpin for RedisPublisher
impl UnsafeUnpin for RedisPublisher
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<P> ErasedPublisher for Pwhere
P: Publisher,
impl<P> ErasedPublisher for Pwhere
P: Publisher,
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