The controller is responsible for managing invocations to completion. It makes use of the scheduler to determine the strategy towards the completion of these invocations. It makes use of the InvocationApi, FunctionApi and WorkflowApi to perform actions.
The controller can best be described as an interruptable control loop. It contains the following ways of managing the lifecycle of invocations.
- Long control loop
- Short control loop
- Notification interruption
The long control loop has a frequency measured in seconds. In this control loop, the controller will refresh the cache and check the event store for any active invocation. This is meant to avoid missing any invocations that for whatever reason did not make it into the controller's active invocation cache.
The short control loop has a frequency as high as possible performance-wise (most likely somewhere between 100-1000 ms) The controller checks for updates on invocations in its active invocation cache. This is meant to capture any invocations of which the notification (see notification section) did not occur.
The notification resembles more or less an interrupt. Whenever a relevant event occurs for an invocation, the controller receives a notification of this event. Note that notifications are entirely optional, and only serve to reduce the latency of a workflow invocation. In case of errors or an overload of notifications, the short or long control loop will pick up the invocation. The controller is not obligated to handle a notification.
The controller can be represented in the following steps.
- Controller evaluation is triggered for a invocation.
- Controller gathers required data needed for the evaluation (workflow definition, invocation).
- Controller submits the invocation to the scheduler for evaluation.
- Scheduler evaluates the current state of the invocation.
- Scheduler responds with a set of actions for the controller to undertake.
- Controller interprets the received actions, and executes them concurrently.
- The actions (invoking/pausing tasks) result in new events being added
- The new events of a specific invocation result trigger step 1.