Tokio NSQ

GitHub Actions crates.io

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

Tokio NSQ is available as a cargo package, and API documentation is available on docs.rs.

Versioning

This project follows strict semantic versioning. While pre 1.0.0 breaking changes have only a minor version bump.

Basic consumer example

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

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

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

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

let messagebodystr = std::str::fromutf8(&message.body).unwrap(); println!("message body = {}", messagebody_str);

message.finish(); ```

Basic producer example

```rust let topic = NSQTopic::new("names").unwrap();

let mut producer = NSQProducerConfig::new("127.0.0.1:4150").build();

// Wait until a connection is initialized assertmatches!(producer.consume().await.unwrap(), NSQEvent::Healthy()); // Publish a single message producer.publish(&topic, b"alice1".tovec()).unwrap(); // Wait until the message is acknowledged by NSQ assert_matches!(producer.consume().await.unwrap(), NSQEvent::Ok()); ```

Features