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 github.com/netflix/conductor/client/go
Implementing a Task a Worker
task package provides the types used to implement the worker. Here is a reference worker implementation:
package task
import (
"fmt"
)
// 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
}
Worker Polling
Here is an example that shows how to start polling for tasks after defining the tasks.
package main
import (
"github.com/netflix/conductor/client/go"
"github.com/netflix/conductor/client/go/task/sample"
)
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)
}
NewConductorWoker parameters
- baseUrl: Server address.
- threadCount: No. of threads. Number of threads should be at-least same as the number of workers
- pollingInterval: Time in millisecond between subsequent polls
See
https://github.com/Netflix/conductor/tree/main/polyglot-clients/go
for the source code and follow us on GitHub for updates.
Top comments (0)