[zeromq-dev] Fwd: Exact matching on subscription topics
Chuck Remes
cremes.devlist at mac.com
Wed Jan 18 17:57:02 CET 2012
On Jan 18, 2012, at 10:41 AM, Staffan Gimåker wrote:
> Do you have any opinions on how the public API for this should look? I've started implementing this stuff so it'd be nice to know sooner rather than later :D
>
> I'm thinking along the lines of just adding more socketops for this, e.g.:
>
> zmq_setsockopt(sock, ZMQ_SUBSCRIBE_EXACT, topic, topic_len);
>
> Any other suggestions?
I think that is a good start. Once the code is working and available for other people to bang on, we'll get more input. Let me think out loud for a little here to see what everyone likes...
Alternative #1
I agree that zmq_setsockopt() is the place to put it. I would recommend making two new enums, one more exact matching and the second to eventually replace a "deprecated" ZMQ_SUBSCRIBE option.
e.g.
#define ZMQ_SUBSCRIBE_PREFIX_MATCH ZMQ_SUBSCRIBE
#define ZMQ_SUBSCRIBE_EXACT_MATCH <int>
This would provide some room to grow if the library were to ever get a more complex matching mechanism like regular expressions.
#define ZMQ_SUBSCRIBE_REGEX_MATCH <int>
On the flip side, we also need to be able to delete/unsubscribe with these filters.
#define ZMQ_UNSUBSCRIBE_PREFIX_MATCH ZMQ_UNSUBSCRIBE
#define ZMQ_UNSUBSCRIBE_EXACT_MATCH <int>
etc
Alternative #2
We deprecate the use of zmq_setsockopt() for setting subscription filters and create a dedicated mechanism for accomplishing this task.
e.g.
zmq_setsockfilter(void * socket, int operation, void * operation_value, size_t operation_len);
This new API call would only work with ZMQ_SUB sockets. Passing any other socket type would return the appropriate error (-1) and set errno to ENOTSUP.
All of the suggested #defines from above would be the same here.
cr
More information about the zeromq-dev
mailing list