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
impl NSQProducer
sourcepub async fn consume(&mut self) -> Option<NSQEvent>
pub async fn consume(&mut self) -> Option<NSQEvent>
Consume message acknowledgements, and connection status updates.
sourcepub async fn publish(
&mut self,
topic: &Arc<NSQTopic>,
value: Vec<u8>
) -> Result<(), Error>
pub async fn publish( &mut self, topic: &Arc<NSQTopic>, value: Vec<u8> ) -> Result<(), Error>
Queue a PUB message to be asynchronously sent