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

  • A smart constructor validating an NSQ channel name
  • Configuration options shared by both produces and consumers
  • NSQD TLS encryption options
  • An NSQD consumer corresponding to multiple NSQD instances.
  • Configuration object for an NSQ consumer.
  • Configuration object for NSQLookup nodes
  • A smart constructor validating a deflate compression level
  • 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.
  • An NSQD producer corresponding to a single instance.
  • Configuration object for an NSQ consumer
  • A smart constructor validating an NSQ sample rate
  • A smart constructor validating an NSQ topic name

Enums