-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Simplify Event Store plugin registration #232
Comments
So if you want to register a plugin, you have to do it outside in the factory? What I really liked is EventStore->setup($plugin); and the rest is hidden. |
@codeliner your thoughts? |
Let's use the same mechanism as we have for service-bus
This way attaching plugins work always the same no matter the component. Thoughts? |
sounds good. will provide a pr if none of you guys is faster :) |
I have to take back my last comment - the issue is not solvable like this. Let me explain with the problem of dual-plugins (a plugin for command bus and event store). In message-bus we have this:
if we add now the same for event-store, the plugin attach() method needs to know, which action event listener is passed (from command-bus or from event-store) in order to attach correctly to the given action event emitter. Method overloading would be great, like: Unfortunately PHP is lacking support of it. So we have two options I think:
In this case, we can do type checks within the plugin itself and check if we have an event store, a message bus or something else. This is kind of bad, as I really like typed parameters.
In this case I just don't like the name of the methods, but that's perhaps something we have to live with. Any better ideas? |
Another option: We make these new and add a new |
It's about the event target, not the event names. While it would work with additional if checks, it's not really a good solution |
interface EventStorePlugin
{
public function attachToEventStoreEmitter(ActionEventEmitter $actionEventEmitter): void;
} ? |
I am working on this, will submit a PR maybe tomorrow. |
From a user POV I think it's a little bit confusing how to register plugins. The
\Prooph\Snapshotter\SnapshotPlugin
plugin is a good example. To register a plugin in the Event Store, each plugin must implement thesetUp
method.Why don't we use an
attach
/detach
method likeZend\EventManager
has. I guess it's more intuitive to register the plugin in an Event Store instead of registering the Event Store in the plugin, which then registers the plugin in the Event Store with$eventStore->->getActionEventEmitter()->attachListener(...)
. The Event Store should implement.If we use this, I guess we also don't need to expose the action event emitter with
getActionEventEmitter
.The same behavior is used for Service Bus plugins. Maybe we should switch it too? Here is an example
The text was updated successfully, but these errors were encountered: