onInitialize method

  1. @override
bool onInitialize()
override

Callback when this executor is initialized. Returns true if successfully initialized, false otherwise.

Note that this is a non-async method and should hence be 'light-weight' and not block execution for a long duration.

Implementation

@override
bool onInitialize() {
  _group.add(_controller.stream);

  // get the trigger executor and initialize with this task control executor
  if (ExecutorFactory().getTriggerExecutor(taskControl.triggerId) == null) {
    triggerExecutor = ExecutorFactory()
        .createTriggerExecutor(taskControl.triggerId, trigger);
    triggerExecutor?.initialize(trigger, deployment);
  }
  triggerExecutor =
      ExecutorFactory().getTriggerExecutor(taskControl.triggerId);
  triggerExecutor?.triggerEvents.listen((_) => onTrigger());

  // get the task executor and add the measurements it collects to the stream group
  taskExecutor = ExecutorFactory().getTaskExecutor(task);
  taskExecutor?.initialize(task, deployment);
  _group.add(taskExecutor!.measurements);

  return true;
}