conductor-sdk / conductor-csharp

The conductor-csharp repository provides the client SDKs to build task workers in C#
Apache License 2.0
41 stars 16 forks source link

IWorkflowTask has been made synchronous #64

Closed madsph closed 1 year ago

madsph commented 1 year ago

I am upgrading my application from an older version of the SDK. We are using a Background Service and IWorkflowTaskCoordinator to execute IWorkflowTask.

Much to my surprise, the Execute method of IWorkflowTask has been made synchronous, which is a real pain, since many of our workers are performing tasks on databases, making http requests, and other stuff that would naturally be async.

Since polling for tasks is also an HTTP request, I guess that the whole execution must already be in an async context, so it must have required some work to remove it from IWorkflowTask. In other words I guess this must have been done for a very good reason, which I have a hard time figuring out what is.

Can you explain the reason why this was decided or if there is another way that executing async tasks is meant to be performed? Right now I feel like I have to choose between sticking to an obsolete version or write my own framework. I don't like either of those paths.

gardusig commented 1 year ago

Sorry for not communicating it properly - now the SDK contains batch polling. Which means - you can poll for many tasks at once, internally it starts a new thread for each polled task. Whatever is done inside each thread, won't block the others. It now makes sense to wait for the task execution synchronously, since it has its own thread.