stan-rs

License Apache 2 Crates.io

NATS Streaming client wrapper built on top of NATS.rs

Just a very early prototype.

Supports publishing and basic subscription.

Installation

toml [dependencies] nats = "0.9.7" stan = "0.0.3"

Example useage:

```rust use nats; use stan; use std::{io, str::from_utf8};

fn main() -> io::Result<()> { let nc = nats::connect("nats://127.0.0.1:4222")?; let client = stan::connect(nc, "test-cluster", "rust-client-1")?;

println!("Connected: {:?}", client);

println!("sending message 1");
client.publish("foo", "hello from rust 1")?;

let sub_handler = client.subscribe("foo", Some("foo-2"), None)?.with_handler(|msg| {
    println!("{:?}", from_utf8(&msg.data));
    Ok(())
});

client.publish("foo", "hello from rust 2")?;
client.publish("foo", "hello from rust 3")?;

sub_handler.unsubscribe()?;

client.publish("foo", "hello from rust 4")?;
Ok(())

}

```

Development

To start a local nats streaming server for testing:

docker run -p 4222:4222 -p 8222:8222 nats-streaming