-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
[Workflow] Choose which Workflow events should be dispatched #36617
Comments
I think this is a good idea. Do you want to try to submit a pr? If you can't it not an issue at all. I will do it |
Thanks @lyrixx I would love to submit a PR, do you have any suggestions on how I would approach this? Do you have a preference on whether the optional config item should be a, "which events should be fired", or a "which events shouldn't be fired"? My current thinking is to add a new method into
Thoughts? |
Let's be positive:
The configuration could live in the Thanks |
Maybe also remove the code that handle the announce alone? |
Hi both, Have submitted a draft PR beginning this work. Have removed the code that handled announce alone. A few things to note:
Thoughts? |
i think it is ok to keep it, only
agreed, metadata must be "external" config, not framework config |
…atched (stewartmalik, lyrixx) This PR was merged into the 5.2-dev branch. Discussion ---------- [Workflow] Choose which Workflow events should be dispatched | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #36633 ; Fix #36617 | License | MIT | Doc PR | Commits ------- cfc53ad [Workflow] Choose which Workflow events should be dispatched (fix previous commit) d700747 [Workflow] Choose which Workflow events should be dispatched
Description
Provide a way to choose which events are to be dispatched by the Workflow component.
Background
Currently I have an application that processes orders. See below for Workflow places and transitions:
I have workflows that assist in maintaining the state of the order. Currently my code listens for Guard Events and performs some action based on the state of the workflow.
For example when attempting to place an order via a third party API I have implemented a Guard Event Listener for the
send
transition. In the EventListener I attempt to call the third party API to place the order, if this fails I return a TransitionBlocker which prevents the transition from taking place. This all works perfectly.My current issue is that when a transition has taken place successfully, the Workflow component calls the
announce()
method so that we can find which new transitions are now possible for the new place. The issue with this is that theannounce()
method eventually callsbuildTransitionBlockerListForTransition()
but with possible transitions for the new place the order is in. In the above example if thesend
transition completes successfullybuildTransitionBlockerListForTransition()
is called withsave_order_id
as the transition.This then dispatches the Guard Event for the
save_order_id
transition even though we’ve only explicitly called Workflow->apply() on thesend
transition. The effect of this is that Guard Event Listeners for thesave_order_id
transition fire prematurely.While this isn’t an issue for some transitions of the Workflow, for Guard Event Listeners that contact a third party API, or perform some kind of state change with the order, it means this state change happens before we explicitly call the transition where it should occur. Then when we actually call the next transition ourselves sometime later it happens for a second time.
Proposal
Provide some method of choosing which events the Workflow component should dispatch for a specific workflow.
In an ideal scenario I think this could be added as an optional configuration item for each workflow definition. An array that contains all events that should be dispatched, or the inverse, an array that defines which events should be excluded from being dispatched.
For example:
Thank you for taking the time to read this proposal :)
The text was updated successfully, but these errors were encountered: