An alternative solution would be using a plugin to label the events.
This is how we could achieve it:
- intercept all the Events before they get fired from the
- create a new event type (i.e.:
EventEnvelope) as a wrapper of the Event class, containing the
instanceNameas an additional field
- all the plugins which need to know the origin of an Event will have to use the
EventEnvelopeclass as a base class to extend Events from
This will label all the events, but the replication one, which are fundamental in a multi-master setup.
To label the replication events the core plugin will need to be modified to expose
postEvent method and allow to override it.
This would create dependency among plugins, which is a complicated pattern.
Linking of the plugins into the /lib directory would be complex, since we will have to make sure the base plugin is loaded before the dependant one.
Also, a different JSON payload for the stream events, depending if you have or not the plugin to enrich them, will be generated.
Same consideration as in the proposed solution.