Open jean-airoldie opened 5 years ago
This would be a way better approach https://github.com/zeromq/libzmq/issues/3658.
This would essentially allow us to configure a socket to receive notifications in Msg
based on a set of interests. The interests would be something like a bitflag that would tell zmq what events we are interested it. By default, sockets would have no interests, aka. stateless.
Here are the possible approaches for passing events to the user:
Msg
let msg = client.recv_msg()?;
if msg.is_notif() {
match msg.notif() {
Notif::Disconnected => ...,
_ => ...,
}
} else {
// proceed like normal.
}
Msg
let msg = client.recv_msg()?;
match msg.content() {
Content::Bytes(bytes) => ...,
Content::Notif(notif) => ...,
}
match client.recv_msg() {
Ok(msg) => ...,
Err(err) => match err.kind() {
ErrorKind::Notif(notif) => ...,
_ => ...,
}
}
So I think that the notification as an error approach is the best one. Even if there is some metadata contained within the message, we can retrieve it and give it back to the client.
By leveraging the
zmq_socket_monitor
API, allow sockets to receive events that are normally discarted bylibzmq
. Allow the user to configure what events should be received or discarded.See #122 for more information.