skip to Main Content

I am trying to come up with a JSON representation of workflow that is composed of both synchronous and asynchronous tasks.

For example:

  Run A then B 
  
  When B is done 

  Execute C and D at the same time

  wait for C and D to finish

  Execute E 

  Wait for E to finish 

  execute F and G at the same time

  Wait only for G and then 

  Execute H

I am not aware if there is a standard way to represent this.

This is my attempt :

 {    
    "tasks":[
        {"A":""},
        {"B":""},
        [{"C":""},{"D":""}],
        {"E":""},
        [{"F":""},{"G":""}]
    ]
  }

Every {} runs serially/synchronously after the previous in the same array.

ie B will run only after A is done.

C and D will run together at same time after B is done.

E will run only when C and D are done.

F and G will run at the same time after E is done.

Now I want to wait only for G and don’t care about F before executing H. That I am not sure how to represent.

2

Answers


  1. I would go with more explicit approach – for every task, include list of tasks on which its execution depends on:

    tasks: {
        {key: "A"},
        {key: "B", dependsOn: ["A"]},
        {key: "C", dependsOn: ["B"]},
        {key: "D", dependsOn: ["B"]},
        {key: "E", dependsOn: ["C", "D"]},
        {key: "F", dependsOn: ["E"]},
        {key: "G", dependsOn: ["E"]},
        {key: "H", dependsOn: ["G"]}
    }
    
    Login or Signup to reply.
  2. Yet another way to describe the steps

    {
      "steps": [
       { "start": ["A"],      "after": []         },
       { "start": ["B"],      "after": ["A"]      },
       { "start": ["C", "D"], "after": ["B"]      },
       { "start": ["E"],      "after": ["C", "D"] },
       { "start": ["F", "G"], "after": ["E"]      },
       { "start": ["H"],      "after": ["G"]      },
      ]
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search