Pure graph implementation for the orchestration system#1258
Conversation
process node then delegate to children if possible
| @@ -0,0 +1,41 @@ | |||
| package workflow | |||
|
|
|||
| // // Predicate is the type of conditions that can be applied in a filter of a workflow trigger | |||
There was a problem hiding this comment.
keep this in comment to reuse it to manage the filters on another PR
| @@ -0,0 +1,178 @@ | |||
| package workflow | |||
There was a problem hiding this comment.
This is basically a file renaming from algorithm.go to graph.go but with a new graph struct
| "github.com/sirupsen/logrus" | ||
| ) | ||
|
|
||
| // Scheduler manages the executions based on the definition of the workflows |
There was a problem hiding this comment.
This package got bigger with PR and still, there is not a single test :/
There was a problem hiding this comment.
this actually makes the scheduler smaller and yes I agree it needs testing, this is based on the sdk and don't have any mock for it so it's hard to reproduce behaviors. But yes I will add some tests on another PR
There was a problem hiding this comment.
and don't have any mock for it so it's hard to reproduce behaviors.
Please don't use mocks. Rather then mocks try to organize the code so it could be unit tested.
But yes I will add some tests on another PR
This functionality is in this PR so I think the tests should also be here. It's not the first pr about graph without testing and PR about filter has already been started. I'm ok to add them in PR about filters, but not later.
NicolasMahe
left a comment
There was a problem hiding this comment.
manual test are working good 👍
do you want to do the modif in this PR or in another one?
|
@antho1404 can you update the workflow in description so they can work with the latest modif? |
|
description updated |
This PR changes the way we designed the workflow.
Instead of having a graph only for the tasks and trigger this graph of tasks when a trigger is matched. We now include the trigger as a node of this graph and we process all the dependencies for this node (this even allows a multi-tree of tasks based on the same trigger or event multiple triggers).
The mapping has also been considered as a node in order to be able to chain them and reduce the complexity of a task node and providing more flexibility in the future.
Benefits:
With this structure where everything is a node, we can easily switch to a graph database where different objects type are different nodes in the database and so having better performances on the lookup of the nodes to resolve. It also provides the flexibility to add new types of processing.
Here is the graph structure:
Nodes:
nodeKeyis execution, it will find the matching outputs in the execution's graph, otherwise, it will map based on the previous current data (from a trigger or another mapping)Edges:
Classic edges composed of
srcanddstthat can connect any kind of nodeTo Test:
3 services:
2 types of workflow:
serviceA#eventX=>serviceA#taskX=>map(inputA: serviceA#taskX.value)=>serviceB#taskY{ "key": "Event", "nodes": [ { "event": { "key": "trigger:event", "instanceHash": "6hDyE3NurqLtxgV4AtXMpLemNMEzvEiTgDDwtxjZzdPR", "eventKey": "eventX" } }, { "task": { "key": "node1", "taskKey": "taskX", "instanceHash": "6hDyE3NurqLtxgV4AtXMpLemNMEzvEiTgDDwtxjZzdPR" } }, { "map": { "key": "map1", "outputs": [{ "key": "inputA", "ref": { "nodeKey": "node1", "key": "value" } }] } }, { "task": { "key": "node2", "taskKey": "taskY", "instanceHash": "2iLAvYeJu78wi4Y4sHBKmVYnM3PVVqP8gpCocUnnLJBH" } } ], "edges": [ { "src": "trigger:event", "dst": "node1" }, { "src": "node1", "dst": "map1" }, { "src": "map1", "dst": "node2" } ] }serviceB#taskY=>map(message: serviceB#taskY.res)=>serviceC#taskZ{ "key": "result-from-other-workflow", "nodes": [ { "result": { "key": "trigger:result", "instanceHash": "2iLAvYeJu78wi4Y4sHBKmVYnM3PVVqP8gpCocUnnLJBH", "taskKey": "taskY" } }, { "task": { "key": "task1", "instanceHash": "FXGpKzcEHMnyr2BQrH44Dq2SoAYtjw1C7qNRVGbxTNpa", "taskKey": "taskZ" } }, { "map": { "key": "map", "outputs": [ { "key": "message", "ref": { "nodeKey": "trigger:result", "key": "res" } } ] } } ], "edges": [ { "src": "trigger:result", "dst": "map" }, { "src": "map", "dst": "task1" } ] }Happy hacking :)