3 releases

Uses old Rust 2015

0.1.2 Nov 7, 2018
0.1.1 Mar 3, 2018
0.1.0 Mar 3, 2018

#28 in #msgpack

MIT license

9KB
169 lines

asink

docs.rs Build Status

Asynchorous sink wrapper for time-series data


lib.rs:

Async sink of time-series data based on serde-rs

Example

extern crate asink;
extern crate serde;
#[macro_use]
extern crate serde_derive;

use asink::*;
use std::sync::mpsc::Sender;

/// This will be serialized into msgpack
#[derive(Serialize)]
struct Doc {
    id: usize,
    data: Vec<f64>,
}

fn experiment(s: Sender<Doc>) {
    for i in 0..5 {
        let doc = Doc {
            id: i,
            data: vec![i as f64],
        };
        s.send(doc).unwrap(); // Send data to sink
    }
}

fn main() {
    let sink = msgpack::MsgpackSink::from_str("test.msg");
    let (s, th) = sink.run(); // Sink start thread to write recieved data into msgpack
    experiment(s);
    th.join().unwrap();
}

Dependencies

~13MB
~261K SLoC