pushpin
pushpin copied to clipboard
wildcard subscriptions
It would be useful to subscribe to channels by wildcard. For example, a publisher could publish a message to channel A.B.C
, and a receiver with subscription to A.*
could receive the message.
Wildcard subscriptions are not uncommon in publish-subscribe systems, however they tend to work differently in each system. For example, ZeroMQ supports filtering by prefix. Bayeux supports segmented channels and trailing wildcards of either single segment or multi-segment (e.g. /a/*
matches /a/b
, and /a/**
matches /a/b/c/d
). At least in these two cases, wildcarding is effectively suffix only, which is pretty conservative and seems like something we could reasonably do in Pushpin.
Proposal:
- If a subscribed channel ends with a single asterisk, then it should count as a wildcard. For example:
Grip-Channel: foo.*
. - Pushpin should subscribe to the channel without the asterisk on its ZeroMQ SUB socket. A subscription to
foo.*
would usefoo.
as the SUB socket filter.
Note that ZeroMQ being limited to filtering by prefix doesn't necessarily mean that we can't support more complex wildcarding. For example, a mid-string wildcard like foo*bar
could be supported by setting the SUB socket to use foo
as the filter, but then only deliver to clients if the full expression matches. However we should only implement something like this if there is a real need. For most applications needing wildcards, suffix-only is usually enough.
Some more notes:
- Stats subscription events should advertise the channel with the asterisk.
-
Grip-Last
request headers should include the channel with the asterisk (origin will be responsible for doing whatever is right). -
prev-id
checking per connection needed for reliability may not make sense with wildcard subscriptions? - Update trigger after first subscriber may not make sense either?