It is a Design Problem which I am listing out here.
I have multiple event sources in my app, each one produces events with the different set of data (but each source is producing only one type of event). On the other side, I've got multiple actions, that can be triggered by sources.
Sources and actions may be extended in future (There may be more of them).
Which action is triggered when is stated in a configuration that can be changed during runtime - in other words, user suppose to have opportunity to say, for example, "when source 1 will produce event, then fire action 2" or "when source 2 will produce event, then fire action 1 and action 2" etc.
What's more, events should be able to be filtered based on their settings, for example, the user can set "when source 1 will produce the event, then fire action 2 but only when the produced event contains date lower than today"
I've tried to draw something to maybe better illustrate my problem (and solution I was thinking of):
As it is written in the picture, I think that kind of mediator pattern should be used here.
But I have the following problems:
I'm not sure if the mediator is a good place for filtering. I've marekd that configuration is injected here, but still not sure about it.
Each of actions should be able to handle each of source - but since events are different, without the same ancestor, each action will have to be able to consume each event type. So when adding a new source, I will need to add handling method in each action. And I'm thinking if there is a way to avoid that.