Multi step workflow#1201
Merged
NicolasMahe merged 12 commits intodevfrom Aug 8, 2019
Merged
Conversation
krhubert
reviewed
Aug 1, 2019
5c411be to
3765b02
Compare
5fab386 to
1aa2933
Compare
6 tasks
krhubert
approved these changes
Aug 5, 2019
NicolasMahe
reviewed
Aug 5, 2019
Member
NicolasMahe
left a comment
There was a problem hiding this comment.
The workflow should be based on simple yet generic graph definition (nodes and edges).
The engine should check for the graph complexity (only directive and radius of 1).
| panic("parent hash should be present if event is not") | ||
| } | ||
| if exec.ParentHash.Equal(exec.Hash) { | ||
| panic("parent hash cannot be equal to execution hash") |
Member
There was a problem hiding this comment.
should return the error, no?
| } | ||
|
|
||
| func (w *Workflow) triggerExecution(wf *service.Workflow, prev *execution.Execution, eventHash hash.Hash, data map[string]interface{}) error { | ||
| height, err := w.getHeight(wf, prev) |
Member
There was a problem hiding this comment.
As discussed, the calculation of the height bring a few problems mainly when the workflow is circular (or multiple workflow are).
The height could be saved directly in the Execution.
Also, height is only valid for mono-branch workflow, fine for now but big limitation for the future.
NicolasMahe
approved these changes
Aug 8, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #1197
TODO:
Testing:
Note that the CLI is not yet updated for that so you will need to use the GRPC API directly.
We will create the following workflow:
These services are just accumulator that take a message in input and return a message that is the concatenation of the input plus the task executed.
You can find the services here:
ServiceA:
{"name":"serviceA","tasks":[{"inputs":[{"type":"String","key":"message"}],"outputs":[{"type":"String","key":"message"}],"key":"taskX"},{"key":"emits"}],"events":[{"data":[{"type":"String","key":"message"}],"key":"eventX"}],"configuration":{},"hash":"9P49TPmeToJDb2vSLwv3iovz56UWJJinRMhM3TMkEcEw","sid":"serviceA","source":"QmUojyMjo2JUvhktLU4royUBDEsVzU4z1onPovGpVQAFDW"}ServiceB:
{"name":"serviceB","tasks":[{"inputs":[{"type":"String","key":"message"}],"outputs":[{"type":"String","key":"message"}],"key":"taskY"}],"configuration":{},"hash":"3vZaZD59AUzxMAaRREFFR2XEKvU6mYDVv5UweTgSQF4c","sid":"serviceB","source":"Qmf2e92jNxxmYyjxEFrCBJdCNUS1LKNWet2ZQt3ByEUpAP"}ServiceC:
{"name":"serviceC","tasks":[{"inputs":[{"type":"String","key":"message"}],"outputs":[{"type":"String","key":"message"}],"key":"taskZ"},{"inputs":[{"type":"String","key":"message"}],"outputs":[{"type":"String","key":"message"}],"key":"taskA"}],"configuration":{},"hash":"EvYgwFjAQpGs19EgoXi4EExJXoH7DL6Fmae4RStQZzt2","sid":"serviceC","source":"QmPuHX3LumnDkrxY3wUR8J2J9xmXGw8yTVy5jf7P24MprN"}Once these services are created and started you can write the following workflow:
{ "sid": "workflow", "name": "workflow", "source": "QmbtKRgiDxB8dChfdRA2Hk7MYtB1yB3dXrnh2msus7Ft8P", "workflows": [ { "key": "event", "trigger": { "type": 1, "instanceHash": "88YtHw3iZtjpAeDDUWHsDFg9MLvgircPzCFHxFqJ2ex9", "key": "eventX" }, "tasks": [ { "instanceHash": "8qKUdaMPAn35ozeUWVcT9BQ5gHNJYbJJ5rTCWqfnJgpW", "taskKey": "taskY" }, { "instanceHash": "7sTRCDpWCXYBSVgh7dKKV6pP69PHdYQY8kyBohumEWNu", "taskKey": "taskZ" } ] }, { "key": "result", "trigger": { "type": 2, "instanceHash": "88YtHw3iZtjpAeDDUWHsDFg9MLvgircPzCFHxFqJ2ex9", "key": "taskX" }, "tasks": [ { "instanceHash": "8qKUdaMPAn35ozeUWVcT9BQ5gHNJYbJJ5rTCWqfnJgpW", "taskKey": "taskY" }, { "instanceHash": "7sTRCDpWCXYBSVgh7dKKV6pP69PHdYQY8kyBohumEWNu", "taskKey": "taskZ" } ] }, { "key": "result-from-other-workflow", "trigger": { "type": 2, "instanceHash": "8qKUdaMPAn35ozeUWVcT9BQ5gHNJYbJJ5rTCWqfnJgpW", "key": "taskY" }, "tasks": [ { "instanceHash": "7sTRCDpWCXYBSVgh7dKKV6pP69PHdYQY8kyBohumEWNu", "taskKey": "taskZ" } ] } ] }Where
88YtHw3iZtjpAeDDUWHsDFg9MLvgircPzCFHxFqJ2ex9: Hash of instance of serviceA8qKUdaMPAn35ozeUWVcT9BQ5gHNJYbJJ5rTCWqfnJgpW: Hash of instance of serviceB7sTRCDpWCXYBSVgh7dKKV6pP69PHdYQY8kyBohumEWNu: Hash of instance of serviceCNow if you execute taskX from serviceA all the tasks of the workflow will be triggered.
You can also try with events by calling the
emitstask fromserviceAwith no inputs