Skip to main content

Crate tokio_nsq

Crate tokio_nsq 

Source
Expand description

A Rust NSQ client built on Tokio. Tokio NSQ aims to be a feature complete NSQ client implementation.

§A basic consumer example:

 use tokio_nsq::*;

 let topic   = NSQTopic::new("names").unwrap();
 let channel = NSQChannel::new("first").unwrap();

 let mut addresses = std::collections::HashSet::new();
 addresses.insert("http://127.0.0.1:4161".to_string());

 let mut consumer = NSQConsumerConfig::new(topic, channel)
    .set_max_in_flight(15)
    .set_sources(
        NSQConsumerConfigSources::Lookup(
            NSQConsumerLookupConfig::new().set_addresses(addresses)
        )
    )
    .build();

 let mut message = consumer.consume_filtered().await.unwrap();

 let message_body_str = std::str::from_utf8(&message.body).unwrap();
 println!("message body = {}", message_body_str);

 message.finish();

§Logging

Logging for Tokio NSQ is done via the common log facade. If you desire logs from Tokio NSQ you must integrate an additional crate implementing the log API such as env_logger, or simple-logging.

Structs§

NSQChannel
A smart constructor validating an NSQ channel name
NSQConfigShared
Configuration options shared by both produces and consumers
NSQConfigSharedTLS
NSQD TLS encryption options
NSQConsumer
An NSQD consumer corresponding to multiple NSQD instances.
NSQConsumerConfig
Configuration object for an NSQ consumer.
NSQConsumerLookupConfig
Configuration object for NSQLookup nodes
NSQDeflateLevel
A smart constructor validating a deflate compression level
NSQMessage
An NSQ message. If this message is dropped with being finished and the respective NSQ daemon connection still exists the message will automatically by requeued.
NSQProducer
An NSQD producer corresponding to a single instance.
NSQProducerConfig
Configuration object for an NSQ consumer
NSQSampleRate
A smart constructor validating an NSQ sample rate
NSQTopic
A smart constructor validating an NSQ topic name

Enums§

NSQConfigSharedCompression
NSQD TCP compression options
NSQConsumerConfigSources
The strategy a consumer should use to connect to NSQD instances
NSQEvent
An event from an NSQ connection. Includes connection status updates, errors, and actual NSQ messages.
NSQRequeueDelay
Control what delay strategy the client will use for calculating requeue timeout