Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fun with applied FP
Subscribers subscribe to topics.
A topic is expressed as a period delimited namespace: "a.b.c.d"
A topic subscription may be an exact match or use wild card characters:
* - match 1 namespace segment at a specific location
# - match any number of namespace segments
When a message comes in, it will always have a fully specified topic.
The list of subscriptions with topics that would match the message's topic is the desired outcome.
Assume that given the entire set of all possible topics that would match the message's topic,
there exists an engine that can very quickly assess which subscription topics exist in the set.
Can you provide an efficient solution to find the entire set of possible topic matches given
a message topic?
Examples:
Message topic: 'a.b'
Full set:
'a.b'
'a.*'
'a.#'
'*.b'
'#.b'
'*.*'
'#'
Message topic: 'a.b.c'
Full set:
'a.b.c'
'a.b.*'
'a.b.#'
'a.*.*'
'a.*.#'
'a.#.*'
'a.#'
'*.b.c'
'#.b.c'
'*.b.*'
'*.b.#'
'#.b.*'
'#.b.#'
'*.*.c'
'#.c'
'#'
'*.*.*'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment