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.
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.
Parameter | Description | Required/ Optional |
---|---|---|
cacheConfig.ttlInSecond | The time to live in seconds, which is the duration for the output to be cached. | Required if using cacheConfig. |
cacheConfig.key | The 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.
Parameter | Description | Required/ Optional |
---|---|---|
taskDefinition.enforceSchema | Whether to enforce schema validation for task inputs/outputs. Set to true to enable validation. | Optional. |
taskDefinition.inputSchema | The name and type of the input schema to be associated with the task. | Required if enforceSchema is set to true. |
taskDefinition.outputSchema | The 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.
Parameter | Description | Required/ Optional |
---|---|---|
optional | Whether 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:
- 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.
- 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.