Skip to main content

Quickstart 1: Write a Worker

Estimated time: 5min

As you will have learned in Core Concepts, the core units of every Conductor workflow are tasks and operators. System tasks are serviced by Conductor workers, but you can also create custom workers to service custom logic for your workflows.

Custom workers can be deployed anywhere: container, VM, or bare metal.

In this quickstart, you will:

  1. Download a worker project.
  2. Integrate the worker with Conductor.
  3. Deploy the worker from your local machine.

Download a worker project

Begin by creating a task worker that polls the Conductor server for scheduled tasks at regular intervals. To get started quickly, download one of our sample myTask worker projects in your preferred language:

gh repo clone conductor-oss/conductor-apps

Integrate the worker with Conductor

To connect your task worker with the Conductor server, you must:

  1. Register your worker by creating a task definition
  2. Create a worker application and grant it Execute permission

To register your worker:

  1. Log in to your Orkes cluster or Orkes Developer Edition.
  2. In the left navigation menu of the Conductor UI, go to Definitions > Task.
  3. Select (+) Define task.
  4. Enter the Name for the task, which must match the task definition name in your worker code. This must be myTask if you are using the sample worker project downloaded in the previous step.
  5. Select Save > Confirm Save.

The task is now saved to the Conductor server, which facilitates the routing of the task to the correct worker pool during workflow execution.

Finally, your worker requires programmatic access to the Conductor server. This can be done by creating an application in Conductor, which is an access layer with its own permissions and access tokens.

note

If you are using Orkes Developer Edition, you can only create one application with the Admin role enabled.

To create an application for your worker:

  1. In the left navigation menu of the Conductor UI, go to Access Control > Applications.

  2. Select (+) Create application and enter a Name for it. For example, myApp or myWorkerApp.

  3. Enable the Worker application role, which allows the application to poll and update tasks.

  4. Select (+) Create access key and store the generated credentials securely.

  5. Set the Key ID and Key Secret in your project.

    Example (Python)

    def main():
    configuration = Configuration(base_url='https://developer.orkescloud.com',
    authentication_settings=AuthenticationSettings(key_id='_CHANGE_ME_',
    key_secret='_CHANGE_ME_'))
  6. (Skip this step if you are using Orkes Developer Edition) Grant Execute permission to the application.

    1. Under Permissions, select Add permission.
    2. Select the Task tab and then your worker task “myTask”.
    3. Enable the Execute toggle.
    4. Select Add Permissions.

The application account can now execute the worker task.

Start the worker

Using the command line, launch the worker so that it begins polling the Conductor server. The commands depend on your language and project configuration. You can follow the README instructions in the sample worker project to start it.

Example (Java)

./gradlew build
./gradlew run

Later, when you run a workflow containing this worker, the task should run to completion. But first, let’s build a first workflow using this task in Quickstart 2.