DEV Community


Posted on

Go: Netflix Conductor Worker

What is Conductor

Conductor is a Microservices orchestration platform from Netflix, released under Apache 2.0 Open Source License.

Download and start Conductor server in 5 minutes


Install Golang package

go get
Enter fullscreen mode Exit fullscreen mode

Implementing a Task a Worker

task package provides the types used to implement the worker. Here is a reference worker implementation:

package task

import (

// Implementation for "task_1"
func Task_1_Execution_Function(t *task.Task) (taskResult *task.TaskResult, err error) {
    log.Println("Executing Task_1_Execution_Function for", t.TaskType)

    //Do some logic
    taskResult = task.NewTaskResult(t)

    output := map[string]interface{}{"task":"task_1", "key2":"value2", "key3":3, "key4":false}
    taskResult.OutputData = output
    taskResult.Status = "COMPLETED"
    err = nil

    return taskResult, err
Enter fullscreen mode Exit fullscreen mode

Worker Polling

Here is an example that shows how to start polling for tasks after defining the tasks.

package main

import (

func main() {
    c := conductor.NewConductorWorker("http://localhost:8080", 1, 10000)

    c.Start("task_1", "", sample.Task_1_Execution_Function, false)
    c.Start("task_2", "mydomain", sample.Task_2_Execution_Function, true)
Enter fullscreen mode Exit fullscreen mode

NewConductorWoker parameters

  1. baseUrl: Server address.
  2. threadCount: No. of threads. Number of threads should be at-least same as the number of workers
  3. pollingInterval: Time in millisecond between subsequent polls

for the source code and follow us on GitHub for updates.

Top comments (0)