Skip to main content

OutgoingMessage

Struct OutgoingMessage 

Source
pub struct OutgoingMessage {
    pub payload: Bytes,
    pub key: Option<String>,
    pub ordering_key: Option<Bytes>,
    pub event_time_ms: Option<u64>,
    pub properties: Vec<(String, String)>,
    pub deliver_at_ms: Option<i64>,
    pub replication_clusters: Vec<String>,
    pub txn_id: Option<TxnId>,
}
Expand description

Convenience alias for outgoing application messages.

Wraps a Bytes payload plus optional pb::MessageMetadata overrides. The producer state machine assigns the sequence id and stamps publish time on send.

Fields§

§payload: Bytes

Application payload bytes.

§key: Option<String>

Optional message key (sets partition_key).

§ordering_key: Option<Bytes>

Optional ordering key.

§event_time_ms: Option<u64>

Optional event time (millis since epoch).

§properties: Vec<(String, String)>

Optional per-message properties.

§deliver_at_ms: Option<i64>

Optional absolute deliver-at time (millis since epoch). Mirrors Java’s TypedMessageBuilder#deliverAt; the broker holds the message until the deadline.

§replication_clusters: Vec<String>

Optional explicit replication cluster list. Mirrors Java’s TypedMessageBuilder#replicationClusters. An empty vector means “use the namespace default”; pass vec!["__local__".to_owned()] to opt out of replication entirely (Java’s disableReplication() writes the same sentinel).

§txn_id: Option<TxnId>

Optional transaction id (PIP-31). When set, the broker treats this publish as part of the open transaction. Mirrors Java Producer#newMessage(Transaction).

Implementations§

Source§

impl OutgoingMessage

Source

pub fn with_payload(payload: impl Into<Bytes>) -> Self

Construct an OutgoingMessage from raw payload bytes.

Source

pub fn key(self, key: impl Into<String>) -> Self

Set the routing key.

Source

pub fn ordering_key(self, key: impl Into<Bytes>) -> Self

Set the ordering key.

Source

pub fn event_time_ms(self, ts: u64) -> Self

Set the event time (milliseconds since epoch).

Source

pub fn property(self, key: impl Into<String>, value: impl Into<String>) -> Self

Append a property.

Source

pub fn deliver_at_ms(self, ts_ms: i64) -> Self

Mirrors TypedMessageBuilder#deliverAt. The broker holds the message until the supplied UNIX-epoch millisecond deadline before dispatching it.

Source

pub fn deliver_after_ms(self, now_ms: i64, delay_ms: i64) -> Self

Mirrors TypedMessageBuilder#deliverAfter. Stamps the message with now_ms + delay_ms as the absolute UNIX-epoch millisecond deadline. The caller supplies now_ms so this stays sans-io-pure (ADR-0011 invariant #3): the tokio engine convenience methods snapshot the host clock at the call site; the moonpool engine plugs in a virtual wall clock so the resulting wire bytes are deterministic across seeds. Use Self::deliver_at_ms for the absolute-deadline variant.

Source

pub fn replication_clusters(self, clusters: Vec<String>) -> Self

Mirrors TypedMessageBuilder#replicationClusters. Overrides the namespace-default replication list with the given clusters for this message only.

Source

pub fn disable_replication(self) -> Self

Mirrors TypedMessageBuilder#disableReplication. Sentinel for “do not replicate this message to any other cluster” — the broker recognises the __local__ cluster id.

Source

pub fn txn(self, txn_id: TxnId) -> Self

Mirrors Java Producer#newMessage(Transaction). Stamps the supplied transaction id on the publish so the broker treats it as part of the open transaction (PIP-31).

Source

pub fn value(self, payload: impl Into<Bytes>) -> Self

Set the payload bytes. Mirrors Java TypedMessageBuilder#value(byte[]) for the raw bytes case — schema-encoded values land here after the schema-aware layer serialises them. Lets the builder be constructed OutgoingMessage::default().key(..).value(..) without forcing the caller through Self::with_payload.

Source

pub fn send(self, producer: &Producer) -> SendFut

Send this message through producer and return the in-flight magnetar_runtime_tokio::SendFut. Mirrors the terminal send() step of Java’s TypedMessageBuilder: producer.newMessage().key(..).value(..).send(). Equivalent to producer.send(msg.into()), just chainable.

Trait Implementations§

Source§

impl Clone for OutgoingMessage

Source§

fn clone(&self) -> OutgoingMessage

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OutgoingMessage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for OutgoingMessage

Source§

fn default() -> OutgoingMessage

Returns the “default value” for a type. Read more
Source§

impl From<OutgoingMessage> for OutgoingMessage

Source§

fn from(msg: OutgoingMessage) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more