pub struct ServerTxPublisher { /* private fields */ }Expand description
The live publisher backed by AMQP server transactions (tx.select / tx.commit /
tx.rollback).
Between begin_transaction and
commit messages accumulate on the broker inside the
channel transaction and become visible atomically at commit;
abort rolls them back server-side. Outside a transaction
publish behaves like the fire-and-forget publisher.
Only the borrowed transaction kind (TransactionalPublisher) applies here, unlike
ConfirmsPublisher: tx.select puts the channel itself into transactional mode, so the
transaction is channel state with exactly one instance, and there is no buffer for an owned
Transaction value to own.
Clones share the transactional channel and its open/closed state. Interleaving publish
and begin_transaction/commit from concurrent tasks is not supported: which side of the
transaction boundary a concurrent publish lands on would be a race either way. Like every
live publisher it aliases the connection and may outlive it: after shutdown every operation
reports AmqpError::Closed.
Trait Implementations§
Source§impl Clone for ServerTxPublisher
impl Clone for ServerTxPublisher
Source§impl Debug for ServerTxPublisher
impl Debug for ServerTxPublisher
Source§impl Publisher for ServerTxPublisher
impl Publisher for ServerTxPublisher
Source§type Payload = Lend
type Payload = Lend
basic_publish takes the payload as &[u8] and copies it into the frame it sends, so
this publisher reads the bytes and keeps nothing.
Source§async fn publish(
&self,
msg: OutgoingMessage<'_>,
options: Option<&Self::Options>,
) -> Result<(), Self::Error>
async fn publish( &self, msg: OutgoingMessage<'_>, options: Option<&Self::Options>, ) -> Result<(), Self::Error>
Publishes msg: into the open server transaction, or plainly when none is open.
The AMQP basic properties are options resolved over the policy’s defaults, either way.
§Errors
Returns AmqpError::Closed once the broker has shut down and AmqpError::Publish
when the channel rejects the frame.
§Cancel safety
Not cancel safe: dropping the future may leave the message queued in the transaction or not.
Source§type Options = LapinPublishOptions
type Options = LapinPublishOptions
QoS, a priority, an ordering key, whatever this
transport lets one message differ from the next in. Read moreSource§impl TransactionalPublisher for ServerTxPublisher
impl TransactionalPublisher for ServerTxPublisher
Source§async fn begin_transaction(&self) -> Result<(), Self::Error>
async fn begin_transaction(&self) -> Result<(), Self::Error>
Opens a server transaction (tx.select on first use).
§Errors
Returns AmqpError::Transaction when a transaction is already open on this handle
(the open transaction is left untouched), AmqpError::Closed once the broker has shut
down, and AmqpError::Publish when the transactional channel cannot be set up.
Source§async fn commit(&self) -> Result<(), Self::Error>
async fn commit(&self) -> Result<(), Self::Error>
Commits the open server transaction.
§Errors
Returns AmqpError::Transaction when no transaction is open, and
AmqpError::Publish when tx.commit fails; the transaction state on the broker is
then unknown (the channel may be closed) and the publisher should be discarded.
Source§async fn abort(&self) -> Result<(), Self::Error>
async fn abort(&self) -> Result<(), Self::Error>
Rolls back the open server transaction.
§Errors
Returns AmqpError::Transaction when no transaction is open, and
AmqpError::Publish when tx.rollback fails.
Auto Trait Implementations§
impl !RefUnwindSafe for ServerTxPublisher
impl !UnwindSafe for ServerTxPublisher
impl Freeze for ServerTxPublisher
impl Send for ServerTxPublisher
impl Sync for ServerTxPublisher
impl Unpin for ServerTxPublisher
impl UnsafeUnpin for ServerTxPublisher
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
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 moreSource§impl<P> PublishExt for P
impl<P> PublishExt for P
Source§fn message<'a, T>(
&'a self,
value: &'a T,
) -> PublishBuilder<&'a Self, MessageBody<'a, T>, UnnamedCodec, HeadersUnset, <T as OutgoingDestination>::Form>where
T: OutgoingDestination,
fn message<'a, T>(
&'a self,
value: &'a T,
) -> PublishBuilder<&'a Self, MessageBody<'a, T>, UnnamedCodec, HeadersUnset, <T as OutgoingDestination>::Form>where
T: OutgoingDestination,
#[derive(Outgoing)] value, encoded with the crate’s
default codec (name another one with with_codec(..)). A
Serialized value’s bytes leave as they are instead - the wire is
the type’s own (MessageWire), and no codec runs on it. Read moreSource§fn begin(
&self,
) -> impl Future<Output = Result<TransactionScope<'_, Self, UnnamedCodec, AnyDeclared>, Self::Error>> + Sendwhere
Self: Sized + TransactionalPublisher,
fn begin(
&self,
) -> impl Future<Output = Result<TransactionScope<'_, Self, UnnamedCodec, AnyDeclared>, Self::Error>> + Sendwhere
Self: Sized + TransactionalPublisher,
TransactionScope that
owns it. Read moreSource§fn owned_transaction(
&self,
) -> impl Future<Output = Result<TypedTransaction<Self::Transaction, UnnamedCodec, AnyDeclared>, Self::Error>> + Sendwhere
Self: Sized + OwnedTransactions,
fn owned_transaction(
&self,
) -> impl Future<Output = Result<TypedTransaction<Self::Transaction, UnnamedCodec, AnyDeclared>, Self::Error>> + Sendwhere
Self: Sized + OwnedTransactions,
TypedTransaction that owns it. Read more