pub struct TypedMessageBuilder<'a, S: Schema> { /* private fields */ }Expand description
Schema-aware counterpart to crate::MessageBuilder. Captures a &TypedProducer
and lets callers chain Java-style: producer.new_message().key(..).value(&typed).send().
The schema runs on .send(&value) so we don’t pay the encode cost on values that get
dropped mid-build (a logic error caught by the borrow checker, but cheap to be
defensive about).
Implementations§
Source§impl<S: Schema> TypedMessageBuilder<'_, S>
impl<S: Schema> TypedMessageBuilder<'_, S>
Sourcepub fn key(self, key: impl Into<String>) -> Self
pub fn key(self, key: impl Into<String>) -> Self
Set the routing key. See crate::OutgoingMessage::key.
Sourcepub fn ordering_key(self, key: impl Into<Bytes>) -> Self
pub fn ordering_key(self, key: impl Into<Bytes>) -> Self
Set the ordering key. See crate::OutgoingMessage::ordering_key.
Sourcepub fn event_time_ms(self, ts: u64) -> Self
pub fn event_time_ms(self, ts: u64) -> Self
Set the event time (millis since epoch). See crate::OutgoingMessage::event_time_ms.
Sourcepub fn property(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn property(self, key: impl Into<String>, value: impl Into<String>) -> Self
Append a property. See crate::OutgoingMessage::property.
Sourcepub fn deliver_at_ms(self, ts_ms: i64) -> Self
pub fn deliver_at_ms(self, ts_ms: i64) -> Self
Sourcepub fn deliver_after_ms(self, now_ms: i64, delay_ms: i64) -> Self
pub fn deliver_after_ms(self, now_ms: i64, delay_ms: i64) -> Self
See crate::OutgoingMessage::deliver_after_ms. The caller
supplies now_ms (sans-io, ADR-0011 invariant #3).
Sourcepub fn replication_clusters(self, clusters: Vec<String>) -> Self
pub fn replication_clusters(self, clusters: Vec<String>) -> Self
Sourcepub fn disable_replication(self) -> Self
pub fn disable_replication(self) -> Self
Sourcepub async fn send(self, value: &S::Owned) -> Result<MessageId, PulsarError>
pub async fn send(self, value: &S::Owned) -> Result<MessageId, PulsarError>
Encode value with the producer’s schema and submit. Mirrors Java’s
terminal TypedMessageBuilder#send. PIP-87 AutoProduceBytesSchema producers warm
their broker-schema cache on first invocation via the same path as
TypedProducer::send.