-
Notifications
You must be signed in to change notification settings - Fork 153
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] Spec contents that are difficult to understand #140
Comments
"Why can Delay state types loop?" -- logic could ask this state to repeat/loop for a certain data input. For example "delay 5 seconds for each open order" |
"Why does Delay state type have error handling when there's no action attached (e.g. Relay state type can't)?" -- In order to do a delay implementations will have service to keep track of execution/run time, do the actual timer delay operations etc. This services could raise runtime exceptions possibly which might have to be handled. |
"How can the Switch state type loop when its choices might have transitioned the workflow to another state already?" -- good point! will update asap |
"Why does an Event state contain more than one event definition? This could be a Switch state evaluation that has multiple choices for the received event" - you could if you wanted use switch and delay and operation states to do what event state currently does all in one ..but why would you :) There are always multiple ways of doing things,I do see however that the property "events" is confusing ....prob should look into examples to see how to make this better. wdyt? |
"Why is there a list of actions plus an actionMode that defines if the actions are run in parallel when there is also the Parallel state type?" -- goes back to previous comment about event state,. Parallel state executes a number of states/tasks sequentially or in parallel, for event sate whats being executed are "events" that contain actions. Again you could use switch state with parallel state and operation state i f you wanted. Does not make it wrong either way. |
"What does it mean if an Event-type state loops - would it transition to another state as defined in its EventDef or consume more events?" -- This will be more clear when we introduce internal vs external transitions. Yes currently it is confusing. |
"What if I have parallel branches waiting for external events? Do they consume events or would non-matching events be put back in the queue?" -- dont fully understand the question but I would assume this depends on the timeout property of the "event" in event state as well as particular implementation logic for that scenario. Will definitely look into this some more. |
Suggestion- "reduce the Event state to just wait for an external event and transitions" - this suggestion mas made iirc before so definitely we should look into it. I think there are couple of things to consider:
|
Suggestion - "unify the conditions" - definitely. jsonpath for filters, expression language for conditions would be good imo |
Suggestion - "consider replacing Switch with just a set of conditional transitions" - I looked into that and yes you can do it, however the "choices" make things alot more readable at a low cost. Especially the "or" or "and" ones. |
I just found out that "loop" is required for each state. Should it really be required? I think this field should be optional. |
Suggestion - "replace error handling with just evaluating whatever the action output (i.e. not having the engine detect if the result of an action is a stack trace due to aborted execution or a valid result)" - this suggest there is an output :) Handling runtime exception imo is a must-have to be able to properly define business logic in some cases. Comparing stack traces that can change over time is not a good "maintenance" option imo either. |
@cathyhongzhang that is a typo in the documentation...im already on it . look at https://github.com/cncf/wg-serverless/blob/master/workflow/spec/schema/serverless-workflow-schema-01.json .. "loop" is not defined in any of the required definitions |
Suggestion - "remove loop from attributes and make it its own construct, maybe merge it with subflow" - this is imo (pls dont be mad :) ) not a good option. Look at aws or conductor they have things like the "map state" or "foreach state" .. it looks ugly and is truly non functional. What we did enhances imo what they have ...just need to make sure we dont add it to things that should not loop :) ** Update ** after discussion it seems that we do want a separate state for looping - ok I will work on that then :) |
@manuelstein tried to comment on items in your post best I could :) I'm sure others will have their comments as well. Hope it helped and thanks again for raising this issue. |
Like to add on Tihomir's reply. Parallel state is mainly used for applications that involves embedded sub-workflow while "parallel actions" just specifies the parallel execution of functions (not states). |
It seems "loop" causes quite some confusion. I also find it confused. Although it could be used in some scenarios, I don't feel it is a key attribute that will be used a lot. Adding it to the state construct makes each state look kind of complicated and hard to understand. When people feel a spec is complicated and has a lot to interpret and figure out which one is used for what, people tend not to adopt it. At this stage, it is probably better to minimize optional attributes to make it simple and easy to understand. When adoption picks up, and we find a compelling reason to add a new attribute, we can add it. So I think maybe it is a good idea to move it out of the state construct. |
If my understanding of the correlationToken is correct, then a workflow can receive multiple events through separate sources with the same token, meaning that they all belong to the same workflow activation. IIUC, the first time a token with content "session1" appears, the workflow would start at the startsAt state and subsequent events with the same token "session1" can be consumed by an Event-type state if there is any. |
@cathyhongzhang Looping imo is a key workflow construct for this spec just like branching event handling, transitions, parallel execution, etc. I would be ok with separating looping into its own state, like the map or foreach state others have if that would make it less confusing but taking it out imo is a bad idea. wdyt? |
@tsurdilo I am not saying we should remove it from the spec (sorry that I confuse you). Separating looping into its own state or using another way to move it out of the various state definition will be less confusing and simpler. Thank you for taking care of this! |
@cathyhongzhang its nice we have several improvements already to do from this discussion. If you don't mind could we just first look at the open prs (especially #138 if you don't mind) because it would really save me alot of time not to have to rebase the fixes that are being worked on identified here. thanks! |
@cathyhongzhang also suggestions for the "loop state" name are more than welcome |
To add on Tihomir's point, I think having functions associated with event states makes it compact. The only difference between an event state and an operation state is that execution of functions in the event state are triggered by events(i.e. when workflow transits to this state, it needs to wait there for external events before invoking function execution) while execution of functions in operation state are not triggered by external events (i.e. when workflow transits to this state, it does not need to wait there for external events before invoking function execution). |
@tsurdilo will try to do the review of PR as quick as possible |
@cathyhongzhang i have added the fix for "loop" parameter not to be required as part of existing PR #138. Will work on a separate pr for looping state. |
Regarding "I also noticed the Event state type condition is a string" -- this was fixed via b01dbd8 |
Regarding looping - this is being addressed via #143. Please take a look and review. thanks. |
@manuelstein any comments/suggestions after all the comments here? |
Yes, first of all thank you for the many replies! Still have to go through all of them. Quick one - questions on the Delay state:
|
|
@manuelstein just wanted to add quickly while thinking about your comments and this self-checking..netflix conductor has this feature for states/tasks data input/output. |
@tsurdilo @manuelstein great thread of discussions and I can see that @tsurdilo already implemented a lot of changes... |
@salaboy I think we can close if @manuelstein says his questions have been answered. |
I'm having multiple issues with the spec, but maybe that's just me, so this is an attempt get it sorted out and I'd be happy if you could help me.
Why can Delay state types loop?
Why does Delay state type have error handling when there's no action attached (e.g. Relay state type can't)?
How can the Switch state type loop when its choices might have transitioned the workflow to another state already?
If my understanding of the correlationToken is correct, then a workflow can receive multiple events through separate sources with the same token, meaning that they all belong to the same workflow activation. IIUC, the first time a token with content "session1" appears, the workflow would start at the startsAt state and subsequent events with the same token "session1" can be consumed by an Event-type state if there is any.
I also noticed the Event state type condition is a string, the Switch state type choices are JSON encoded logic, but transitions and error handling use a separate expression language.
I'd suggest to
The step-by-step execution is nice, but maybe the control logic is really independent from triggering functions, e.g. something that allows a more flexible use of control elements - like sleeps, loops, conditions and outside interaction (event send/receive).
The text was updated successfully, but these errors were encountered: