conductor-sdk / conductor-go Goto Github PK
View Code? Open in Web Editor NEWConductor OSS SDK for Go programming language
License: Apache License 2.0
Conductor OSS SDK for Go programming language
License: Apache License 2.0
Test coverage goal:
Similar to code found at Conductor Java SDK
When using taskRunner.WaitWorkers()
I was curious if there is a way to gracefully shut the task runner down.
The documentation says:
WaitWorkers uses an internal waitgroup to block the calling thread until all workers started by this TaskRunner have been stopped.
Which implies, that after stopping all the workers the function WaitWorkers
should stop blocking the calling thread.
After looking at the source code (sdk/worker/task_runner.go
) I found out, that "stopping" a worker means setting it's batch size to zero. This correctly logs to the console, that the worker has been stopped, but the function WaitWorkers
was still blocking the calling thread.
From inspecting the source code this behavior makes sense:
WaitWorkers
function simply waits for the internal wait group to be empty/done.
func (c *TaskRunner) WaitWorkers() {
c.workerWaitGroup.Wait()
}
c.workerWaitGroup.Add(1)
and go c.work4ever()
are executed.work4ever
handles the Done
signal to the c.workerWaitGroup
like this:
func (c *TaskRunner) work4ever(taskName string, executeFunction model.ExecuteTaskFunction, domain string) {
defer c.workerWaitGroup.Done()
defer concurrency.HandlePanicError("poll_and_execute")
for c.isWorkerRegistered(taskName) {
c.workOnce(taskName, executeFunction, domain)
}
}
c.workerWaitGroup.Done()
is only called when the for loop is done. The for loop only stops when c.isWorkerRegistered(taskName)
returns false
. So let's have a look at this function.isWorkerRegistered
it's clear, that the batch size of 0 does not affect the return value of isWorkerRegistered
because it only checks if the task name is present as a key in the map.
func (c *TaskRunner) isWorkerRegistered(taskName string) bool {
c.batchSizeByTaskNameMutex.RLock()
defer c.batchSizeByTaskNameMutex.RUnlock()
_, ok := c.batchSizeByTaskName[taskName]
return ok
}
If this is the expected behavior, the documentation should clearly differentiate between a registered worker and a stopped worker. Also the difference between these two "states" and a paused worker is not clear to me.
In my case I want to dynamically modify the task runner via an REST API. This means adding and "removing" workers at runtime. As there is no clear way on how to "remove" a worker from a task runner I'm unsure if pausing is sufficient, if I should set the batch size to 0 or if I need to create a PR and add a RemoveWorker(...)
functionality which actually deletes task name key from the batchSizeByTaskName
map.
Hopefully someone can help me out on this issue and shine some light on the differences between the different "states" of a worker.
Edit: I have an additional question. Why is there a possible goroutine leak when calling Pause(taskName)
?
Related issue: https://github.com/orkes-io/orkes-conductor/issues/111
Evaluate behavior on invalid credentials:
Change parallel go routines amount to parallels routine count
Issue:
Even though batch size is set as 1. Noticed that 2 tasks were dequeued by the worker.
RCA:
There is a race between getAvailableWorkerAmount() and executeAndUpdateTask() in workOnce() code. Here are the sequence of events:
STEPS to reproduced
BATCH_SIZE is set to 1 in my case.
FIX
Conductor GO SDK need to fix and below PR raised for same . Please take a look and merge it and new release .or let me know whats the process to get it fixed on condutor-go as its blocking our release.
#118
conductor version
conductor-go v1.3.2
Note:
it seems like the Java SDK client has moved away from this design and using TaskRunnerConfig to poll for tasks. But go client isn't quite there yet. But as this is blocking our release we fixed this issue on conductor-go client in below PR
#118
As a user, I would like to have the easiest possible onboard.
Some users might face missing imports. Consider reviewing current guide and add necessary steps as needed. Probably worth mentioning about go mod tidy
- it might solve most problems related to missing package or failed import.
Accept-Encoding: gzip
Replace sleep(1)
approach to use channels instead
Use Orkes Playground Swagger docs as reference: https://play-app.orkes.io/api-docs
Steps:
Hello! Just wondering if there is a function available to parse a JSON workflow into a typed ConductorWorkflow object? Thank you!
Hi ,
I am running conductor as docker-compose in local, and wrote a simple program in go for worker - https://github.com/sandeep540/netflix_conductor
It's running, but not completing task and there are no logs, can you please help me in debuggin where am I going wrong,
P.S: I got it working with java, but we have requirement with go
Hi, just wonder is there any way to create a task with retryCount=0? CauseretryCount
is an "omitempty" attribute.
Also try some other value like retryCount=-1 etc. however there's validation on server side
Maybe using *int32 for retryCount is a better way in TaskDef?
Hi
I am using an API - workflowExecutor.UpdateTask() to pass task status and output, but output is not going to conductor
It's failing at
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.