pub struct LapinPublishOptions {
pub priority: Option<u8>,
pub expiration: Option<Duration>,
pub persistent: Option<bool>,
}Expand description
The AMQP basic properties one publish may differ from the next in.
Every field is optional because a publish carries only what its call site adjusted; the rest is
what the publish policy fixed when it paired the publisher. The policy carries the defaults
(LapinPublish::priority,
expiration,
persistent), the steps of LapinPublishSteps adjust one
message, and the publisher resolves the two before it builds the frame.
A test reads the value back from the slot view: tb.out::<Alerts>().with_options(..) takes
this type, which is why it derives Debug and PartialEq.
§Examples
use ruststream::OutSlot;
use ruststream::testing::TestApp;
use ruststream_lapin::prelude::*;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, PartialEq, Outgoing)]
struct Alert {
level: u8,
}
#[derive(OutSlot)]
#[publishes(Alert)]
struct Alerts;
#[subscriber("alerts.raw")]
async fn escalate(
alert: &Alert,
Out(alerts): Out<impl Publisher<Options = LapinPublishOptions>, Alerts>,
) -> HandlerOutcome {
let sent = alerts.message(alert).to("alerts").priority(alert.level).publish().await;
if sent.is_err() {
return HandlerOutcome::retry();
}
HandlerOutcome::ack()
}
let app = RustStream::new(AppInfo::new("alerts", "0.1.0")).with_broker(
LapinBroker::new("amqp://localhost:5672"),
|b| {
b.include(escalate).out(Alerts, Publish::default()).build();
},
);
let tb = TestApp::start(app).await?;
tb.broker::<LapinBroker>()
.message(&Alert { level: 9 })
.to("alerts.raw")
.publish()
.await?;
tb.out::<Alerts>()
.assert_called_once()
.with_options(&LapinPublishOptions {
priority: Some(9),
..LapinPublishOptions::default()
});Fields§
§priority: Option<u8>The AMQP priority property (0..=255), or None to keep the policy’s.
expiration: Option<Duration>The AMQP per-message expiration (TTL), or None to keep the policy’s. AMQP counts it in
whole milliseconds; a shorter non-zero value becomes one millisecond.
persistent: Option<bool>Whether the message is marked persistent (delivery mode 2), or None to keep the policy’s.
Trait Implementations§
Source§impl Clone for LapinPublishOptions
impl Clone for LapinPublishOptions
impl Copy for LapinPublishOptions
Source§impl Debug for LapinPublishOptions
impl Debug for LapinPublishOptions
Source§impl Default for LapinPublishOptions
impl Default for LapinPublishOptions
impl Eq for LapinPublishOptions
Source§impl PartialEq for LapinPublishOptions
impl PartialEq for LapinPublishOptions
impl StructuralPartialEq for LapinPublishOptions
Auto Trait Implementations§
impl Freeze for LapinPublishOptions
impl RefUnwindSafe for LapinPublishOptions
impl Send for LapinPublishOptions
impl Sync for LapinPublishOptions
impl Unpin for LapinPublishOptions
impl UnsafeUnpin for LapinPublishOptions
impl UnwindSafe for LapinPublishOptions
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