zeromq / zmq.rs

A native implementation of ØMQ in Rust

Home Page:https://crates.io/crates/zeromq

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add missing `zmq_proxy` method

xpepermint opened this issue · comments

Hey, I noticed there is no Proxy component available:

zmq_proxy (frontend, backend, capture);

Originally I planned to add such a method. However currently I'm considering first implemeting this feature #112 . If we'll provide basic Stream/Sink implementation we could use https://docs.rs/futures/0.3.12/futures/stream/trait.StreamExt.html#method.forward method. I'll try to prioritize this features if they are important to you

Thanks, mate!

I've added a prototype implementation of proxy function.

It looks like that using native StreamExt::forward doesn't cover case with duplex messaging (frontend <--> backend). Cause it looks like that it's only suitable for case frontend --> backend

Cause of this I've added a generic function with API similar to the one that zmq provides.
One of the drawbacks of such impl is that it requires both sockets to implement both SocketSend and SocketRecv with is not the case for some sockets (pub for example only implements SocketSend).
For such cases I think we can still use stream.forward

@xpepermint , @TheButlah What do you think?

Thanks, @Alexei-Kornienko for the PR. I appreciate your dedication and fast response. Yes, the proxy should work both ways and you won't be able to do this using the Stream object. The loop with select looks good to me, the interface supports all the required features so I guess this is it. You could just also add a test case for this new feature so we have it all covered.

Consider to be closed for now. May come back to it later in case of any issues.