[Messenger] Add messenger configuration to make a message bus not get all handlers by default #42693
+13
−4
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.
When working with multiple Messenger buses, it's common to restrict a handler to certain bus(es) using the tag properties. This is useful if you have handlers that all belong to specific buses, but becomes more complicated when there are more combinations of (default and non-default) buses and handlers.
For example if you have a bus to handle new messages and want to introduce a bus that only handles a migrations process' messages in the background. If the handlers for "new messages" should keep handling only those, then you'd suddenly need to make that explicit for all those handlers, because otherwise they'd be added to the "migration process" bus too. And if a third party bundle also registers message handlers, you'd need to restrict those to the specific bus(es) too, if even possible.
This can be improved (IMHO) with a simple addition, by adding a configuration value for the messenger configuration (
framework.messenger.buses[].default_handlers
) that determines if the bus is added by default to handlers. This then stores this config in a tag property, which can be read in theMessengerPass
. The change would be fully backwards compatible. I'd first like to know if this is in line with the Messenger component's way of working and something that could be added. I can add/fix tests, codestyle etc after discussion.