jean-airoldie / libzmq-rs

A strict subset of ØMQ with an ergonomic API.
https://jean-airoldie.github.io/libzmq-rs/
Apache License 2.0
58 stars 4 forks source link

Support event monitoring #23

Open jean-airoldie opened 5 years ago

jean-airoldie commented 5 years ago

Support the zmq_socket_monitored_versioned API to retrieve events for sockets.

My inital idea is to create a unique monitor_addr for each socket. Then we would call zmq_monitor_versioned with this addr to create a ZMQ_PUB monitor socket. The we could create a SocketMonitor which would leverage a ZMQ_SUB and subscribe to the appropriate events. It would then unpack the data into a SocketEvent enum and feed it to a user provided closure. If there is no significant overhead, we should enable that by default.

We could use the same API to create a event logger.

This is required to fix #19.

jean-airoldie commented 5 years ago

From my benchmarks creating a socket monitor that listens to all events has no performance impact.

jean-airoldie commented 5 years ago

It makes sense since:

jean-airoldie commented 5 years ago

Closed by c6024c47d8e930bafd84876a3f881c1a6e29be7f

jean-airoldie commented 5 years ago

Nevermind the commit was reverted. Created a branch that supports monitoring experimentally.

jean-airoldie commented 5 years ago

I'm really unsure if I like socket monitoring tbh. Can't think of any real use case.