Skip to content

Add support of results for workflow triggers#1182

Merged
antho1404 merged 5 commits intodevfrom
feature/workflow-with-result
Jul 16, 2019
Merged

Add support of results for workflow triggers#1182
antho1404 merged 5 commits intodevfrom
feature/workflow-with-result

Conversation

@antho1404
Copy link
Copy Markdown
Member

@antho1404 antho1404 commented Jul 14, 2019

The workflow is now listening to the following streams

  • Events
  • Executions (filtered by completed executions only)

If it receives a matching even, it creates an execution with the event hash and the event data
If it receives a matching execution, it creates an execution with the parent execution hash and the output of the parent execution

To test:

Current workflow implemented:

return []*workflow{
{ // When result of taskA() -> (a string, b string), execute taskB(a string, b bool)
Trigger: trigger{InstanceHash: instanceHash, Type: Result, Key: "taskA"},
Task: task{InstanceHash: instanceHash, TaskKey: "taskB"},
},
{ // When event started(a string), execute taskA(a string)
Trigger: trigger{InstanceHash: instanceHash, Type: Event, Key: "started"},
Task: task{InstanceHash: instanceHash, TaskKey: "taskA"},
},

Service here

  • Create the service
  • Listen for executions (do not start the service yet)
  • Start the instance (with --env EVENT_INTERVAL=0 to remove useless logs)

You should see 2 executions, one with the evenHash (event start) and the other with a parentHash (result of taskA)

You can trigger another one with
mesg-cli service:execute test-workflow taskA --data a=hello

And see again 2 executions, one from the CLI (with an eventHash) the second from the workflow (with an parentHash)

@antho1404 antho1404 added enhancement New feature or request help wanted Extra attention is needed proposal labels Jul 14, 2019
@antho1404 antho1404 self-assigned this Jul 14, 2019
@antho1404 antho1404 added this to the next milestone Jul 14, 2019
@NicolasMahe
Copy link
Copy Markdown
Member

I really think all the Engine should be based on event and it will be simpler to have only one type of data to pass consensus on the network.

This was referenced Jul 15, 2019
@antho1404
Copy link
Copy Markdown
Member Author

Based on the last meeting, we continue with this implementation but we simplify it.

  • Executions don't need an event, either they have an event hash OR a parent hash
  • Removing the event from the exection.Create function and pass inputs directly

@antho1404 antho1404 force-pushed the feature/workflow-with-result branch from f358719 to e880622 Compare July 15, 2019 10:26
@antho1404 antho1404 removed help wanted Extra attention is needed proposal labels Jul 15, 2019
@antho1404 antho1404 force-pushed the feature/workflow-with-result branch from e880622 to 631b4c0 Compare July 16, 2019 03:16
@antho1404 antho1404 merged commit e0dd42a into dev Jul 16, 2019
@antho1404 antho1404 deleted the feature/workflow-with-result branch July 16, 2019 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants