Workflow structures

Sequential Tasks

If you want to wait for a task’s end before continuing, just do

$a = (new TaskA)->execute();
$b = (new TaskB)->execute();
const a = await new TaskA().execute();
const b = await new TaskB().execute();
const a = yield this.run.task("TaskA");
const b = yield this.run.task("TaskB");
a = TaskA.new.execute
b = TaskB.new.execute
a = TaskA().execute()
b = TaskB().execute()
var a int
var b int
TaskA.New().Execute().Output(&a)
TaskB.New().Execute().Output(&b)

Here, task B will be executed only after task A ended.

Parallel Tasks

If you want to launch any number of tasks in parallel just do:

[$a, $b, $c] = (new Zenaton\Parallel\Parallel(new TaskA, new TaskB, new TaskC))->execute();
const { Parallel } = require("zenaton");

const [a, b, c] = await new Parallel(
    new TaskA(),
    new TaskB(),
    new TaskC()
).execute();
const [a, b] = yield this.run.task(["TaskA", param1], ["TaskB", param2]);
a, b, c = Zenaton::Parallel.new(TaskA.new,TaskB.new, TaskC.new).execute
a, b, c = Zenaton.parallel.Parallel(TaskA(),TaskB(), TaskC()).execute()
var a int
var b int
var c int

task.Parallel{
    TaskA.New(),
    TaskB.New(),
    TaskC.New(),
}.Execute().Output(&a, &b, &c)

Here, tasks A, B and C will be executed in parallel, and we wait for all of them to end before continuing, and return an array of results.

Asynchronous Tasks

If you do not want to wait for a task’s end before continuing, just do

$a = (new TaskA)->dispatch();
$b = (new TaskB)->execute();
// 'await' is important here, because even if we are not waiting for TaskA's end
// we need to make sure it has been properly scheduled
const a = await new TaskA().dispatch();
const b = await new TaskB().execute();
const a = this.run.task("TaskA");
const b = yield this.run.task("TaskB");
            
a = TaskA.new.dispatch
b = TaskB.new.execute
a = TaskA().dispatch()
b = TaskB().execute()
TaskA.New().Dispatch()
var b int
err = TaskB.New().Execute().Output(&b)

Here, task B will be executed without waiting for the end of task A.