pub struct JetStreamPublisher { /* private fields */ }Expand description
The live JetStream publisher. Cheap to clone.
Every publish waits for the stream’s acknowledgement, so a rejected message (unknown stream,
violated expectation, storage failure) is an error rather than a silent drop. Like the Core
publisher it aliases the connection and may outlive it: after the broker shuts down every
publish reports NatsError::Closed.
Implementations§
Source§impl JetStreamPublisher
impl JetStreamPublisher
Sourcepub async fn publish_ack(
&self,
msg: OutgoingMessage<'_>,
) -> Result<PublishAck, NatsError>
pub async fn publish_ack( &self, msg: OutgoingMessage<'_>, ) -> Result<PublishAck, NatsError>
Publishes into the stream and returns the acknowledgement: the stream the message landed in, its sequence there, and whether the deduplication window recognised it as a duplicate.
Publisher::publish is this call with the acknowledgement discarded.
§Errors
Returns NatsError::Closed when the broker has shut down, NatsError::Publish when
the message cannot be sent, and NatsError::JetStream when the stream rejects it (no
such stream, or an expectation from the policy did not hold).
§Cancel safety
Not cancel-safe: dropping the future after the message is on the wire abandons the acknowledgement, leaving the publish in an indeterminate state.
Trait Implementations§
Source§impl Clone for JetStreamPublisher
impl Clone for JetStreamPublisher
Source§fn clone(&self) -> JetStreamPublisher
fn clone(&self) -> JetStreamPublisher
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more