postal.js currently supports wildcard topic bindings by providing two special characters that can be used in a binding. The current implementation works as follows:
- Topics are period-delimited string values. Periods are not required, but if they are included, the section of alpha-numeric text between periods is referred to as a word or topic segment.
- Current wildcard characters:
- * - an asterisk acts as a wildcard for any length of the topic.
- "Home*" would match "Home.Sweet.Home" and "Homeless.Programmer"
- "Home.*" would match "Home.Sweet.Home, but not "Homeless.Programmer"
- # - a hash symbol current matches one "word" of a topic.
- "Home.# would match "Home.Boy" but not "Home.Sweet.Home"
- * - an asterisk acts as a wildcard for any length of the topic.
#Y U WANT CHANGE POSTAL?
- I've borrowed key conceptual ideas from AMQP, and want to remove this mental 'impedance mismatch'
- Future postal.js endeavors include bridging instances of postal with RabbitMQ and other 3rd party libraries that use the AMQP style approach. Consistency is key.
- postal.js is still young enough for this to not be a major disruption.
- Starting with postal v0.6.5, postal will include the AMQP style bindings resolver as something that can be opted into. It will still use the current implementation by default.
- No later than postal v0.7.0, postal will ship with the AMQP style bindings resolver on by default, with the old version available to opt into for backwards compatibility.
- The * matches only one word - that is the alpha-numeric value between periods, or the "leading" or "trailing" word on a topic:
- "Home.*" would match Home.Boy but not Home.Sweet.Home
- "*.Sweet.*" would match Home.Sweet.Home and Cubicle.Sweet.Cubicle but not Something.Sweet.And.Salty
- The # matches 0 or more words in a topic, it will not match partial words
- "Home#" would be an invalid wilcard binding. AMQP rules mean this will be matched as an exact string, so only topics with "Home#" as a topic would match.
- "Home.#" would match "Home.Boy" and "Home.Sweet.Home" and "Home"
- "#.Home" would match "Home.Sweet.Home" and "There.Is.No.Place.Like.Home" and "Home"
That'll teach you to ask for feedback!