pub struct LapinRequest(/* private fields */);Expand description
The request/reply policy: pure declaration, constructible anywhere, pairing into
LapinRequester.
Requests are published transient (delivery mode 1) by default: a request nobody is waiting
for after the timeout gains nothing from surviving a broker restart. Opt into persistence
with persistent(true).
§Examples
use std::time::Duration;
use ruststream::OutgoingMessage;
use ruststream_lapin::prelude::*;
use serde::Deserialize;
#[derive(Deserialize)]
struct Order {
sku: String,
}
#[subscriber("orders")]
async fn place(order: &Order, Out(inventory): Out<impl RequestReply>) -> HandlerOutcome {
let ask = OutgoingMessage::new("inventory.check", order.sku.as_bytes());
match inventory.request(ask, Duration::from_secs(2)).await {
Ok(reply) if reply.payload() == b"in-stock" => HandlerOutcome::ack(),
Ok(_) => HandlerOutcome::drop(),
Err(_) => HandlerOutcome::retry(),
}
}
fn app() -> RustStream {
let broker = LapinBroker::new("amqp://localhost:5672");
RustStream::new(AppInfo::new("orders", "0.1.0")).with_broker(broker, |b| {
b.include(place)
.out(DefaultSlot, LapinRequest::default().exchange("rpc"))
.build();
})
}Implementations§
Source§impl LapinRequest
impl LapinRequest
Sourcepub fn exchange(self, exchange: impl Into<String>) -> Self
pub fn exchange(self, exchange: impl Into<String>) -> Self
Publishes requests to exchange instead of the default exchange.
Sourcepub fn persistent(self, persistent: bool) -> Self
pub fn persistent(self, persistent: bool) -> Self
Whether requests are marked persistent (delivery mode 2). Defaults to false.
One request departs from this with the publish builder’s
persistent step.
Sourcepub fn priority(self, priority: u8) -> Self
pub fn priority(self, priority: u8) -> Self
The AMQP priority property requests carry. Unset by default.
One request departs from this with the publish builder’s
priority step.
Sourcepub fn expiration(self, ttl: Duration) -> Self
pub fn expiration(self, ttl: Duration) -> Self
The AMQP per-message expiration (TTL) requests carry: the broker drops one once ttl
has passed without it being consumed. Unset by default.
Pair it with the per-request timeout: a request that expires on the broker fails with
AmqpError::RequestTimeout at the caller, without a responder ever seeing it.
One request departs from this with the publish builder’s
expiration step.
Trait Implementations§
Source§impl Clone for LapinRequest
impl Clone for LapinRequest
Source§impl Debug for LapinRequest
impl Debug for LapinRequest
Source§impl Default for LapinRequest
impl Default for LapinRequest
impl Eq for LapinRequest
Source§impl LapinPublishPolicy for LapinRequest
impl LapinPublishPolicy for LapinRequest
Source§fn bind(self, connected: &ConnectedLapinBroker) -> Self::Live
fn bind(self, connected: &ConnectedLapinBroker) -> Self::Live
Source§impl PartialEq for LapinRequest
impl PartialEq for LapinRequest
Source§impl PublishPolicy<ConnectedLapinBroker> for LapinRequest
impl PublishPolicy<ConnectedLapinBroker> for LapinRequest
Source§type Live = LapinRequester
type Live = LapinRequester
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: &ConnectedLapinBroker,
) -> impl Future<Output = Result<Self::Live, PairError>>
fn pair( self, connected: &ConnectedLapinBroker, ) -> impl Future<Output = Result<Self::Live, PairError>>
Source§fn channel_bindings(&self, destination: &str) -> Bindings
fn channel_bindings(&self, destination: &str) -> Bindings
AsyncAPI
document. Read moreSource§fn operation_bindings(&self, _destination: &str) -> Bindings
fn operation_bindings(&self, _destination: &str) -> Bindings
send operation in the document. Read moreimpl StructuralPartialEq for LapinRequest
Auto Trait Implementations§
impl Freeze for LapinRequest
impl RefUnwindSafe for LapinRequest
impl Send for LapinRequest
impl Sync for LapinRequest
impl Unpin for LapinRequest
impl UnsafeUnpin for LapinRequest
impl UnwindSafe for LapinRequest
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