1个不稳定版本

使用旧的Rust 2015

0.1.0 2016年8月1日

#5 in #exar

AGPL-3.0

13KB
209

Exar DB客户端

使用Exar DB TCP协议的客户端实现。

Crates.io

文档


lib.rs:

Exar DB客户端

此模块包含使用Exar DB TCP协议的客户端实现。

客户端初始化

extern crate exar_client;

use exar_client::*;

let addr = "127.0.0.1:38580";
let client = Client::connect(addr, "test", Some("username"), Some("password")).unwrap();

发布事件

extern crate exar;
extern crate exar_client;

use exar::*;
use exar_client::*;

let addr = "127.0.0.1:38580";
let mut client = Client::connect(addr, "test", Some("username"), Some("password")).unwrap();

let event = Event::new("payload", vec!["tag1", "tag2"]);

match client.publish(event) {
    Ok(event_id) => println!("Published event with ID: {}", event_id),
    Err(err) => panic!("Unable to publish event: {}", err)
};

查询事件

extern crate exar;
extern crate exar_client;

use exar::*;
use exar_client::*;

let addr = "127.0.0.1:38580";
let mut client = Client::connect(addr, "test", Some("username"), Some("password")).unwrap();

let query = Query::live().offset(0).limit(10).by_tag("tag1");
let event_stream = client.subscribe(query).unwrap();
for event in event_stream {
    println!("Received event: {}", event);
}

依赖

~165KB