Improve bus for large numbers of similar subscriptions #27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, we created a new NATS subscription for each ARI
subscription, which is inefficient for large numbers of similar
subscriptions. (See Issue #26)
With this change, we now retain a single NATS subscription for any
number of ari subscriptions for which the same NATS subscription is
sufficient, regardless of where in the tree of ARI clients it may be.
To do this, we create a root-level (core) back-to-back event bus, with
the NATS subscription being bound to a stdbus ARI bus. All ari-proxy
clients subtend a new SubBus, which forwards all requests on to the core
ARI bus, registering them along the way. When the SubBus is closed, the
bound subscriptions will be closed, but the root-level bus itself will
stay in existence.
There is a remaining issue wherein long-running root-level ari-proxy
clients will accumulate NATS subscriptions and not have them terminate
even after all SubBuses are closed. This will need to be fixed in a
later patch, but it should not affect most uses, for now.
Fixes #26
This change is