conductor icon indicating copy to clipboard operation
conductor copied to clipboard

Custom system tasks require TaskType enum / conductor-common modification

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

Under https://netflix.github.io/conductor/extend/#system-tasks, it says:

To create system tasks follow the steps below:

Extend com.netflix.conductor.core.execution.tasks.WorkflowSystemTask
Instantiate the new class as part of the startup (eager singleton)
Implement the TaskMapper interface
Add this implementation to the map identified by TaskMappers

However, this does not seem to be a complete list of steps required.

In https://github.com/Netflix/conductor/blob/master/core/src/main/java/com/netflix/conductor/core/execution/DeciderService.java#L543 and https://github.com/Netflix/conductor/blob/master/core/src/main/java/com/netflix/conductor/core/execution/DeciderService.java#L569, the registered task mapper is only ever used if a corresponding TaskType enum entry is also added.

It seems that we cannot add our own custom system tasks without modifying TaskType.java in conductor-common?

kyle--lee avatar Jul 30 '19 18:07 kyle--lee

@kyle--lee Correct, custom task will have to be added to TaskType. We'll update the docs to create custom system tasks at the earliest possible. Or, please feel free to send in a PR. Thank you.

kishorebanala avatar Aug 05 '19 23:08 kishorebanala

Update: Custom system tasks are not necessarily added to TaskType, or any other core modules.

For example:

public class CustomTask extends WorkflowSystemTask {
     public CustomTask(...) {
          super(CUSTOM_TASK_NAME);
     }
}

will register the custom task by putting it in the registry map. Also, ensure to initialize CustomTask as eager singleton.

kishorebanala avatar Aug 05 '19 23:08 kishorebanala

@kishorebanala thanks for the response!

I agree, it seems if you can register it and eagerly initialize it, and the system task will be run by Conductor.

However, it doesn't seem like it is possible it register a TaskMapper for it without also modifying TaskType. If this is the case, can I open a PR to update the docs? Are TaskMappers essential for registering a system task?

kyle--lee avatar Aug 06 '19 02:08 kyle--lee

This issue is stale, because it has been open for 45 days with no activity. Remove the stale label or comment, or this will be closed in 7 days.

github-actions[bot] avatar Apr 24 '21 00:04 github-actions[bot]

This issue was closed, because it has been stalled for 7 days with no activity.

github-actions[bot] avatar May 02 '21 00:05 github-actions[bot]