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

Monitor sockets

yan-zaretskiy opened this issue · comments

I'm really excited about this project. Looking forward to dropping the libzmq dependency from my code in favour of zmq.rs. My usage of ZemoMQ is rather lightweight, in fact you already support the features I use (ROUTER/DEALER over TCP). One thing that I think you don't have yet are monitor sockets. I find them very useful when monitoring the connection state. I'm curious whether they are on your Roadmap somewhere in the future? :-)

I see a following possible solution:

  1. create a monitor method on socket. This will create a mpsc channel that will be used to receive monitor events (and give you back a consumer).
  2. Create SocketEvent enum for all events (http://api.zeromq.org/4-1:zmq-socket-monitor)

What is not fully clear is what kind of payload should be in this events. Cause for C++ for example spec says "The event value is the file descriptor (FD) of the underlying network socket. Warning: there is no guarantee that the FD is still valid by the time your code receives this event."

I think I will start with some basic implementation of events and we'll have to see what payload actually makes sense for each event type.

I am not at all familiar with zmq.rs yet, so feel free to discard anything I say. The thought I have is that however you choose to signal the monitor events should use the same mechanism that you use for polling other ZeroMQ sockets in your crate, to mimic how it's done in the regular ZeroMQ library.

As for the payload, again, I am a total noob, but judging by that warning, the FD payload is pretty much useless, so perhaps a plain enum without data would suffice.

commented

Is there any examples on how to check if the connection has dropped? Im trying to figure this out for a while and don't know how to use the monitor