Overview
Workflows are designed to automate a series of one or more steps that are to be taken given a specific trigger. That trigger may be manually invoked (by a person) or automatically invoked (by telemetry).
Each workflow has a definition with five main components, listed in the order they are defined here:
Component | Description |
---|---|
Trigger | The type of trigger. One of: Manual, Event, Metric, Status. Once this is defined, you cannot change it. |
Model | The model to which the workflow applies. |
Name | The name of the workflow. |
Condition | Only applies to Event, Metric and Status triggers. The condition is a logical expression that will be evaluated each time a telemetry message is received to determine if the workflows should be triggered. |
Steps | Steps are individual work items that must be performed in sequence to accomplish the goal(s) of the workflow. |
Workflow Execution
Workflows, whether initiated manually or automatically, are executed in the cloud. The cloud processes each initiated workflow one step at a time. It starts a step, and waits for a result from that step before proceeding. If the step fails, the workflow is terminated. If the step succeeds then the cloud initiates processing of the next step.
Steps are processed either in the cloud or on the device, depending on what the step is trying to accomplish. In general, file transfers are managed by the maiLink agent on the device, as are device-side command, script and executable processing steps. The cloud generally handles distribution of tasks to devices as well as all direct communication steps between maiLink and 3rd party APIs.
Execution Sequence
Every time a workflow gets triggered its steps are added to a queue (including the Device ID). The cloud then begins working its way through the workflow, one step at a time. Each step executes to completion before the could will being processing of the following step, so each workflow is processed synchronously.
In a situation where multiple workflows are initiated for a single device, the cloud will process each workflow synchronously. However it is possible that the steps of different workflows will be interleaved. If one workflow is held up because a step has not finished, another workflow might complete several steps in the meantime.
Note: For this reason, it is important that workflows not have dependencies on the completion (or partial completion) of other workflows.