1 unstable release

Uses old Rust 2015

0.1.0 Aug 1, 2016

#5 in #exar

AGPL-3.0

13KB
209 lines

Exar DB's Client

A client implementation that uses Exar DB's TCP protocol.

Crates.io

Documentation


lib.rs:

Exar DB's client

This module contains a client implementation that uses Exar DB's TCP protocol.

Client Initialization

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();

Publishing events

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)
};

Querying events

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);
}

Dependencies

~165KB