Skip to main content

JetStreamPublishSteps

Trait JetStreamPublishSteps 

Source
pub trait JetStreamPublishSteps {
    // Required methods
    fn message_id(self, id: impl Into<String>) -> Self;
    fn expect_last_sequence(self, sequence: u64) -> Self;
    fn expect_last_subject_sequence(self, sequence: u64) -> Self;
    fn expect_last_message_id(self, id: impl Into<String>) -> Self;
}
Expand description

The per-message JetStream settings, as steps on the publish builder.

A handler body that adjusts one of these names this crate’s prelude and bounds its slot Out<impl Publisher<Options = JetStreamOptions>, Marker>. That body is tied to JetStream, and its signature says so; a body that publishes plainly stays on the framework prelude alone.

The steps sit on the builder rather than on a publisher of their own, so the publish they finish still travels through the mount site’s entry, with the codec and the transforms that entry named.

§Examples

use ruststream_nats::prelude::*;
#[derive(Serialize, Outgoing)]
struct Archived {
    id: u64,
}

ledger
    .message(archived)
    .to("orders.archived")
    .message_id(format!("order-{}", archived.id))
    .expect_last_subject_sequence(41)
    .publish()
    .await?;

Required Methods§

Source

fn message_id(self, id: impl Into<String>) -> Self

Tags this message with a deduplication id, so a repeat inside the stream’s deduplication window is stored once.

Source

fn expect_last_sequence(self, sequence: u64) -> Self

Requires the stream’s last sequence to be sequence, or the stream refuses this message.

Source

fn expect_last_subject_sequence(self, sequence: u64) -> Self

Requires the last sequence on this message’s own subject to be sequence.

Source

fn expect_last_message_id(self, id: impl Into<String>) -> Self

Requires the stream’s last Nats-Msg-Id to be id.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<Sink, Body, Enc, Hdrs, Dest> JetStreamPublishSteps for PublishBuilder<Sink, Body, Enc, Hdrs, Dest>
where Sink: PublishSink<Options = JetStreamOptions>,

The bound on the sink’s options type is what keeps these steps off a builder over any other publisher, this crate’s Core NATS one included.

Source§

fn message_id(self, id: impl Into<String>) -> Self

Source§

fn expect_last_sequence(self, sequence: u64) -> Self

Source§

fn expect_last_subject_sequence(self, sequence: u64) -> Self

Source§

fn expect_last_message_id(self, id: impl Into<String>) -> Self

Implementors§