Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Rust-NATS
Rust-NATS is a Rust client library for the NATS message queue.
The crate is called nats
and can be added as a dependency using Cargo:
= "*"
nats
It was written for Rust-nightly, but support for Rust 1.2 will be added later.
The library was designed to be robust. It doesn't use any usafe code, it never
calls panic!()
and failed commands are automatically retried on different
cluster nodes.
It provides a simple low-level interface that makes it easy to send/receive messages over Rust channels if needed.
Connecting
Single-node client connection:
extern crate nats;
use *;
let client = new.unwrap;
The username and password are optional.
Connecting to a cluster:
let cluster = vec!;
let mut client = new.unwrap;
By default, commands are sent in fire-and-forget mode. In order to wait for an acknowledgment after each command, the synchronous ("verbose") mode can be turned on:
client.set_synchronous;
The client name can also be customized:
client.set_name;
Publishing messages
client.publish.unwrap;
In order to use NATS for RPC, the Client.make_request()
function creates an
ephemeral subject ("inbox"), subscribes to it, schedules the removal of the
subscription after the first received message, publishes the initial request,
and returns the inbox subject name:
let inbox = client.make_request.unwrap;
Subscribing to subjects
Client.subscribe()
adds a subscription to a subject, with an optional group:
let s1 = client.subscribe.unwrap;
let s2 = client.subscribe.unwrap;
With group membership, a given message will be only delivered to one client in the group.
Client.unsubscribe()
removes a subscription:
client.unsubscribe.unwrap;
Receiving events
Client.wait()
waits for a new event, and transparently responds to server
PING
requests.
let event = client.wait;
This returns an Event
structure:
Alternatively, events can be received using an iterator:
for event in client.events