conductor icon indicating copy to clipboard operation
conductor copied to clipboard

SIMPLE vs USER_DEFINED task types, and registering custom system tasks?

Open kyle--lee opened this issue 7 years ago • 2 comments

In the docs and examples, regular worker tasks are listed with type "SIMPLE". However, within https://github.com/Netflix/conductor/blob/master/common/src/main/java/com/netflix/conductor/common/metadata/workflow/TaskType.java, "SIMPLE" tasks are registered as system tasks. I also noticed there is another type, "USER_DEFINED" which is not registered as a system task.

  1. What is the difference between "SIMPLE" and "USER_DEFINED"? Which should we use for worker task definitions?

  2. Is it possible to define custom system tasks without having to modify TaskType.java? The wiki implies that we only need to define a new mapper and hook it up in CoreModule.java, but the logic in DeciderService won't actually call this mapper unless our task is registered as a system task: https://github.com/Netflix/conductor/blob/612cfef6bdd580fe6feb0fe081b34fc54f0b3ace/core/src/main/java/com/netflix/conductor/core/execution/DeciderService.java#L543

        if (TaskType.isSystemTask(type)) {
            taskType = TaskType.valueOf(type);
        }
        .
        .
        .
        List<Task> tasks = taskMappers.get(taskType.name()).getMappedTasks(taskMapperContext).stream()
        .

The reason I'm asking about 2) is that it seems like we would have to fork conductor and modify conductor-common in order to register our own custom system task and mapper.

Thanks!

kyle--lee avatar Jul 19 '19 21:07 kyle--lee

@kyle--lee "USER_DEFINED" task type was introduced as a fallback task type for use internally, which has been called out here.

  1. Please use "SIMPLE" task type for worker task in your workflow definitions.
  2. Yes, it is possible to add your custom system tasks. You would need to extend WorkflowSystemTask with your custom implementation and follow the steps here.

apanicker-nflx avatar Jul 22 '19 23:07 apanicker-nflx

@apanicker-nflx thanks - I'll use SIMPLE type tasks.

For 2 - I saw the steps listed in the docs, but it seems like we also need to add our system task to the TaskType enum in order for the mapper to be called? this is because the DeciderService first does an isSystemTask() call against the task type string, and then does taskMappers.get(taskType.name()). Is this incorrect? It seems that whatever mapper registered will not actually ever be used unless we also add our system task to the TaskType enum.

Thanks!

kyle--lee avatar Jul 23 '19 03:07 kyle--lee