Shutdown hook for conductor workers
Hey,
I am going through the conductor Java client and it seems that there is no function to gracefully shutdown the polling. I was wondering if adding a shutdown() method to stop polling is good idea ?
This shutdown method can be called by the worker in it's shutdown hook during deployments or other graceful shutdowns.
It will also be useful if we want to dynamically add a new worker in the task coordinator without restarts. We can shutdown the old coordinator and start a new coordinator.
Please let me know if this is a good idea. I will be interested in submitting a pull request for the same.
@mudit3774 . It is an excellent idea in my opinion. This would be a good start We don't want for the workers to poll indefinitely and put more load on the server. Ideally the workers should work like lambda functions. Do the work and gracefully shutdown the coordinator.
The better approach would be push tasks to the registered workers instead of polling indefinitely. NIO http APIs may help with push design. This is a research
Thanks for the response @jvemugunta. I will work on the PR.
That is the idea. If we can shutdown the coordinator, a small worker manager should be able to achieve optimizations like time scaling and lamda like functionality.
On push / pull, I am not very sure but think the idea of a poll model is to have a system responsible for the task at all times, either the server or the worker.
@mudit3774 Just saw your idea and code change, that's a good idea for me as well. But I have a question for a running poll service how we can get the running WorkflowTaskCoordinator then shutdown it? is that possible to get the coordinators by exist function or api? Or we should implement is by ourselves?
@JasperB : We have abstracted the workflow clients at our present organization. We wrote a small wrapper over the java client and we maintain a map of task and coordinator. We right now run 1 task in 1 coordinator. The wrapper shuts down the tasks coordinator when we need to stop a task or on worker shutdown. For me it was more of a high level construct. Let me know your thoughts.
@mudit3774 Thank you for the quick reply. It's helpful for us, we also have multiple tasks so we plan to implement the work group, for example several works regarding to one task in one coordinator, then all the coordinators construct in a map with task name as the key, then we can expose a api to shutdown it by task name.