Skip to content

sdgxdev/tokio-nats

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crates.io docs.rs A client for NATS using tokio and async-await. There are still features missing, but it should be ready for use in simple situations.

Installation

[dependencies]
tokio-nats = "0.1.0"

Usage

#![feature(async_closure)]
use tokio_nats::{NatsConfigBuilder, connect};
use futures_util::StreamExt;
async fn demo() {
    let config = NatsConfigBuilder::default()
        .server("127.0.0.1:4222")
        .build()
        .unwrap();
    let mut client = connect(config).await.unwrap();
    client.publish("MySubject", "hello world".as_bytes()).await.unwrap();
    client.subscribe("MyOtherSubject").await.unwrap().for_each(async move |message| {
        println!("Received message {:?}", message);
    }).await;
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%