Crates.io | tokio-zmq |
lib.rs | tokio-zmq |
version | 0.10.1 |
source | src |
created_at | 2018-01-02 02:49:18.380278 |
updated_at | 2019-06-18 16:44:39.461665 |
description | Provides Futures abstractions for ZeroMQ on the Tokio event-loop |
homepage | |
repository | https://git.asonix.dog/asonix/async-zmq |
max_upload_size | |
id | 45169 |
size | 133,301 |
This readme is for the 0.8 branch, for the 0.3 readme, look here
This crate contains wrappers around ZeroMQ Concepts with futures on Tokio's runtime.
Currently Supported Sockets
See the examples folder for usage examples.
futures = "0.1.25"
tokio = "0.1"
tokio-zmq = "0.10.1"
zmq = "0.9.1"
In your application:
use std::sync::Arc;
use futures::{Future, Stream};
use tokio_zmq::{prelude::*, Rep};
fn main() {
let ctx = Arc::new(zmq::Context::new());
let rep_fut = Rep::builder(ctx).bind("tcp://*:5560").build();
let runner = rep_fut.and_then(|rep| {
let (sink, stream) = rep.sink_stream(25).split();
stream
.map(|multipart| {
// handle the Multipart
// This example simply echos the incoming data back to the client.
multipart
})
.forward(sink)
});
tokio::run(runner.map(|_| ()).or_else(|e| {
println!("Error: {:?}", e);
Ok(())
}));
}
The req.rs
and rep.rs
examples are designed to be used together. The rep
example starts a server with a REP socket, and the req
example queries that server with a REQ socket.
The zpub.rs
and sub.rs
examples should be used togheter. zpub
produces values that sub
consumes.
The push.rs
, pull_push.rs
, and pull.rs
files should be used together. push
produces values, which are relayed by pull_push
to pull
, which consumes them and sends a stop signal to itself and to pull_push
.
sync_pubsub.rs
, dealer_router.rs
, and load_balancing_broker
are all self-contained, and spawn multiple threads.
Feel free to open issues for anything you find an issue with. Please note that any contributed code will be licensed under the GPLv3.
Copyright © 2018 Riley Trautman
Tokio ZMQ is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Tokio ZMQ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. This file is part of Tokio ZMQ.
You should have received a copy of the GNU General Public License along with Tokio ZMQ. If not, see http://www.gnu.org/licenses/.