Struct tokio_nsq::NSQProducer

source ·
pub struct NSQProducer { /* private fields */ }
Expand description

An NSQD producer corresponding to a single instance.

Before any messages are published you must wait for an NSQEvent::Healthy() message. If any messages are queued while the connection is unhealthy the publish method shall return an error and the message will not be queued. Messages are queued and delivered asynchronously. Once NSQ acknowledges a message an NSQEvent::Ok() will be available from consume.

Multiple messages can be queued before any are acknowledged. You do not need to wait on consume immediately after each publish. If any NSQEvent::Unhealthy() event is ever returned, all unacknowledged messages up to that point are now considered failed, and must be requeued. A producer will not buffer messages waiting for a healthy connection.

Implementations§

source§

impl NSQProducer

source

pub async fn consume(&mut self) -> Option<NSQEvent>

Consume message acknowledgements, and connection status updates.

source

pub async fn publish( &mut self, topic: &Arc<NSQTopic>, value: Vec<u8> ) -> Result<(), Error>

Queue a PUB message to be asynchronously sent

source

pub async fn publish_deferred( &mut self, topic: &Arc<NSQTopic>, value: Vec<u8>, delay_milliseconds: u32 ) -> Result<(), Error>

Queue a DPUB message to be asynchronously sent

source

pub async fn publish_multiple( &mut self, topic: &Arc<NSQTopic>, value: Vec<Vec<u8>> ) -> Result<(), Error>

Queue an MPUB message to be asynchronously sent

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

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