-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from dimitar-petrov/master
feat: add support for reverse binding between PUB and SUB
- Loading branch information
Showing
8 changed files
with
155 additions
and
25 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
mod async_helpers; | ||
use std::error::Error; | ||
use zeromq::prelude::*; | ||
|
||
#[async_helpers::main] | ||
async fn main() -> Result<(), Box<dyn Error>> { | ||
println!("Start forwarder"); | ||
let mut frontend = zeromq::SubSocket::new(); | ||
frontend.bind("tcp://127.0.0.1:30001").await?; | ||
|
||
let mut backend = zeromq::PubSocket::new(); | ||
backend.bind("tcp://127.0.0.1:30002").await?; | ||
|
||
frontend.subscribe("").await?; | ||
|
||
let forward = async move { | ||
loop { | ||
let message = frontend.recv().await.unwrap(); | ||
println!("passing message: {:?}", message); | ||
backend.send(message).await.unwrap(); | ||
} | ||
}; | ||
|
||
forward.await; | ||
|
||
Ok(()) | ||
} |
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
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
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
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