Tasks
Tasks are the entities that will actually flow through the workflow, allowing stages to communicate with its followings. They carry information in a payload format that may be used to the subsequent stages.Task type
Each task belongs to a type, which is a string defined by the user. This types are used to filter which transitions the task should follow in the workflow.
For example, a Form may classify its tasks in two types: "approved" or "declined", and after this form you can have one transition for each of these task types, leading to different On task scripts, which will proccess these types accordingly.
Task lifecycle
A task has three possible statuses: pending, locked and completed.
When a task is created, it arrives in the stages to which it was sent with the status pending. Therefore, all the tasks received in a stage will be received as a pending task.
When a stage retrieves a task to process it, the task gets locked. This means that if another execution of this stage starts in paralell, the locked tasks won't be retrieved, since they are already being processed by another execution of the stage.
The stage, having this locked tasks in hand during its execution, can complete the tasks. When a task status is set to completed, it no longer will be retrieved as a pending task when the stage runs again, because the status completed means that what should be done with that task was already done.
If the task is not completed within the stage execution, it will automatically return from locked to pending status, waiting for the next run.
Task payload
The task payload is a dictionary which stores useful data. You may store anything in the format key, value to be used in the next stages.