pub struct DirectReplyTo;Expand description
Redirects each reply of a #[subscriber(.., reply(..))] handler to the requester’s
private reply-to address, echoing its correlation id.
This is the canonical responder wiring for request/reply over RabbitMQ direct
reply-to: compose it onto the reply publisher at mount time and the
handler stays a pure request-to-reply function. A request without a reply-to header falls
through to the mount site’s reply("..") name.
The transform names the destination per delivery, so it mounts only where nothing has declared
one: the reply type derives Outgoing without #[outgoing(name = "..")] and the mount site
supplies the fallback name. A reply type that declares its own destination refuses this
transform at the mount site, which is what keeps the generated AsyncAPI document and the wire
in step.
It writes none of the per-message AMQP properties, so it is generic over the publisher’s options and mounts over any of this crate’s publishers. The reply-to address and the correlation id it echoes are protocol fields the crate carries as headers, and the publisher puts them back on the frame.
§Examples
use ruststream_lapin::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Deserialize)]
struct Ask {
sku: String,
}
// An RPC reply goes wherever the request asked, so the destination belongs to the mount
// site and the type declares none.
#[derive(Serialize, Outgoing)]
struct Stock {
available: bool,
}
#[subscriber("inventory.check", reply("inventory.check.unrouted"))]
async fn check(ask: &Ask) -> Stock {
Stock {
available: !ask.sku.is_empty(),
}
}
fn app() -> RustStream {
let broker = LapinBroker::new("amqp://localhost:5672");
RustStream::new(AppInfo::new("inventory", "0.1.0")).with_broker(broker, |b| {
b.include(check)
.out_reply(Publish::default())
.transform(DirectReplyTo);
})
}Trait Implementations§
Source§impl Clone for DirectReplyTo
impl Clone for DirectReplyTo
impl Copy for DirectReplyTo
Source§impl Debug for DirectReplyTo
impl Debug for DirectReplyTo
Source§impl Default for DirectReplyTo
impl Default for DirectReplyTo
impl Eq for DirectReplyTo
Source§impl PartialEq for DirectReplyTo
impl PartialEq for DirectReplyTo
Source§impl<C, Options> PublishTransform<ForReply<C>, Options> for DirectReplyTo
impl<C, Options> PublishTransform<ForReply<C>, Options> for DirectReplyTo
impl StructuralPartialEq for DirectReplyTo
Auto Trait Implementations§
impl Freeze for DirectReplyTo
impl RefUnwindSafe for DirectReplyTo
impl Send for DirectReplyTo
impl Sync for DirectReplyTo
impl Unpin for DirectReplyTo
impl UnsafeUnpin for DirectReplyTo
impl UnwindSafe for DirectReplyTo
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<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
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> ⓘ
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