-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I'll do a writeup later
- Loading branch information
Showing
6 changed files
with
96 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ license = "GPL-3.0" | |
[dependencies] | ||
futures = "0.1" | ||
futures-cpupool = "0.1" | ||
tokio-core = "0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.env | ||
/target/ | ||
**/*.rs.bk | ||
Cargo.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "authentication_zmq" | ||
version = "0.1.0" | ||
authors = ["Riley Trautman <[email protected]>"] | ||
|
||
[dependencies] | ||
authentication_backend = { path = "../authentication_backend" } | ||
authentication_background = { path = "../authentication_background" } | ||
zmq = "0.8" | ||
futures = "0.1" | ||
futures-cpupool = "0.1" | ||
tokio-core = "0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
extern crate zmq; | ||
extern crate futures; | ||
extern crate tokio_core; | ||
|
||
use futures::{Stream, stream}; | ||
use tokio_core::reactor::Core; | ||
|
||
pub struct ZmqResponder { | ||
responder: zmq::Socket, | ||
} | ||
|
||
impl ZmqResponder { | ||
fn connect(&self, bind_addr: &str) -> zmq::Result<()> { | ||
self.responder.connect(bind_addr) | ||
} | ||
} | ||
|
||
impl Iterator for ZmqResponder { | ||
type Item = zmq::Result<Result<String, Vec<u8>>>; | ||
|
||
fn next(&mut self) -> Option<Self::Item> { | ||
Some(self.responder.recv_string(0)) | ||
} | ||
} | ||
|
||
pub fn run() { | ||
let context = zmq::Context::new(); | ||
let responder = ZmqResponder { responder: context.socket(zmq::REP).unwrap() }; | ||
responder.connect("tcp://localhost:5560").expect( | ||
"Failed connecting to responder", | ||
); | ||
|
||
let server = stream::futures_unordered(responder) | ||
.map_err(|_| "some err") | ||
.and_then(|msg| msg.map_err(|_| "some inner err")) | ||
.for_each(|msg| { | ||
println!("Got Message: {}", msg); | ||
|
||
Ok(()) | ||
}); | ||
|
||
let mut core = Core::new().unwrap(); | ||
core.run(server).unwrap(); | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
#[test] | ||
fn it_works() {} | ||
} |
File renamed without changes.