Skip to main content

Worker Task (Simple)

A Worker task (also known as a Simple task) is used to run custom logic implemented in any language. The custom logic can be deployed anywhere and the Worker task requires an external worker for polling.

Prerequisites

Before adding a Worker task to a workflow, you should complete the following:

  • Create a worker to run a custom task.
  • Define the task in Conductor using Conductor UI or API.

For a full guide on how to use workers, refer to Writing Workers.

Task parameters

To configure the Worker task, set its inputParameters as needed for your worker code. The values can be passed as a dynamic input.

Caching parameters

You can cache the task outputs using the following parameters. Refer to Caching Task Outputs for a full guide.

ParameterDescriptionRequired/ Optional
cacheConfig.ttlInSecondThe time to live in seconds, which is the duration for the output to be cached.Required if using cacheConfig.
cacheConfig.keyThe cache key is a unique identifier for the cached output and must be constructed exclusively from the task’s input parameters.
It can be a string concatenation that contains the task’s input keys, such as ${uri}-${method} or re_${uri}_${method}.
Required if using cacheConfig.

Schema parameters

You can enforce input/output validation for the task using the following parameters. Refer to Schema Validation for a full guide.

ParameterDescriptionRequired/ Optional
taskDefinition.enforceSchemaWhether to enforce schema validation for task inputs/outputs. Set to true to enable validation.Optional.
taskDefinition.inputSchemaThe name and type of the input schema to be associated with the task.Required if enforceSchema is set to true.
taskDefinition.outputSchemaThe name and type of the output schema to be associated with the task.Required if enforceSchema is set to true.

Other generic parameters

Here are other parameters for configuring the task behavior.

ParameterDescriptionRequired/ Optional
optionalWhether the task is optional. The default is false.

If set to true, the workflow continues to the next task even if this task is in progress or fails.
Optional.

Task configuration

This is the task configuration for a Worker task.

{
"name": "task_name",
"taskReferenceName": "task_name_ref",
"inputParameters": {},
"type": "SIMPLE"
}

Task output

The Worker task will return the output defined in your worker code.

Adding a Worker task in UI

To add a Worker task:

  1. In your workflow, select the (+) icon to add a new task. There are two ways to add a worker task:
    • Search for your task using its task name (created previously) and select to add it to the workflow.
    • Add a Worker Task (Simple) and enter the task name in Task Definition. This creates a new task definition.
  2. Configure the task, such as its inputs, caching, schema validation, and optionality.

Sample worker code snippets are available in the UI for reference.

Examples

Find an example of how to add and run a Worker task in our Quickstart.