-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
- #23441
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
Comments
Symfony EventDispatcher was designed like hook dispatcher, not "true" event dispatcher. Async processing doesn't make sense for hooks, so it leads to confusion. |
Imho, this is totally off the business of the event dispatcher. For example, when I got an Event, which is bound to a domain model. When I'm now exchanging the event dispatcher with the async one, it's not transparent. It requires dependencies to make it actually work, e.g. the consumer command, the information transport ("transformers") etc. We implemented the same stuff with a few 100 lines of code (including tests) & less overhead. Imho this RFC should be published as an infrastructural bundle with clear dependencies, documentation, rather than putting it into core. Not everything needs to be "core". Imho the Symfony core should focus on stability, performance, security and features for 80%+ projects, not 2% enterprise. Besides that, I don't think "Async Event Dispatcher" is the right name. It's basically a message queue and should be named as it. An "Async Event Dispatcher" which would be really transparent with the behaviour of the current event dispatcher, would be something like https://gist.github.com/havvg/3852361, with direct control which event is dispatched async. This could be implemented transparently as in-memory queue by moving |
I'm not sure I understand this example. When you fire event, you don't care how exactly this thing (event dispatcher, event bus, etc.) will notify event handlers about this event. However, as I said above, Symfony EventDispatcher is not "pure" event dispatcher, it is hook manager that requires to have sync event dispatching, because it allows to modify event object and send it back. On other hand, "pure" event dispatcher/bus is "one way" bus, so it's perfectly fine to have async event handlers, because there is no difference for initiator (the one who runs
It turns out that "Event Dispatcher" is not right name for the Symfony component. :) |
I agree with the naming differences, although in my experience "hook" is not used widely in the PHP world, but it's more like "event" and "messages", respectively. The latter one will be implemented as a message bus, and then you are the point you made: you have decoupled situation. At least that's my experience in the PHP world on this topic, and be revisiting some implementations around "events" and "messages" it's common sense to some degree. I have also seen many of those implementations to be named "event bus" to make it clear, it's kinda "message bus/queue". Let the "wrong" name be; it would be even more important to not coin something with a similar name working completely different, and putting something like "it's transparent" into its description - that's my whole point. |
Just to clarify on the "transparent"; I actually meant, what you mean by transparent:
I think I agree with you on the client - the callee of Don't get me wrong on this, I like the idea as it. I'm just concerned about making it part of the core. |
I understand your point, but I'm trying to say, that it is not clear, for example, when async event handler with higher priority executes later than sync event handler with lower priority. The same question goes to the We have async event handlers in Symfony EventDispatcher as well, but we don't use this tool directly. We use our own |
Uh oh!
There was an error while loading. Please reload this page.
The text was updated successfully, but these errors were encountered: