-
Notifications
You must be signed in to change notification settings - Fork 18
Added Async for the task processing #96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| { | ||
| var taskResult = _executeTaskMethod.Invoke(_workerInstance, new object[] { task }); | ||
|
|
||
| if (token.IsCancellationRequested) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as a user how is the token used to send the request?
| var taskResult = _executeTaskMethod.Invoke(_workerInstance, new object[] { task }); | ||
|
|
||
| if (token.IsCancellationRequested) | ||
| return new TaskResult() { Status = TaskResult.StatusEnum.FAILEDWITHTERMINALERROR, ReasonForIncompletion = "Token Requested Cancel" }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to extract more descriptive message?
Tests/Worker/Workers.cs
Outdated
| throw new Exception("Token request Cancelled"); | ||
| } | ||
|
|
||
| throw new Exception("random exception"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is random exception here? Why do we need to throw exception here? Can we make the message proper?
| throw new System.Exception("random exception"); | ||
| if (token.IsCancellationRequested) | ||
| { | ||
| throw new Exception("Token request Cancelled"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is token request cancellation? How it can be used from callee application side?
| { | ||
| _workflowTaskMonitor.IncrementRunningWorker(); | ||
| System.Threading.Tasks.Task.Run(() => ProcessTask(task)); | ||
| threads.Add(Task.Run(() => ProcessTask(task))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if one thread takes longer duration to execute the task? Let say, there are 100 tasks. 99 completed within second but one task is stuck. Will this create any issues?
| ProcessTasks(tasks); | ||
| var uniqueBatchId = Guid.NewGuid(); | ||
| _logger.LogTrace( | ||
| $"[{_workerSettings.WorkerId}] Processing tasks batch" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need null check on workerSetting.workerId?
| WorkflowTaskExecutorConfiguration WorkerSettings { get; } | ||
| TaskResult Execute(Task task); | ||
| Task<TaskResult> Execute(Models.Task task, CancellationToken token = default); | ||
| TaskResult Execute(Models.Task task); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you mark this as deprecated so its clear that the users should not use this going forward?
@BommannanRa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes @v1r3n We have added deprecate message to the code. When someone try using Execute method, it would show message to move to ExecuteAsync (new implementation).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @BommannanRa let's not change the method name as we want to keep the name consistent with the previous implementation ExecuteAsync should be just Execute
Change Summary
This PR closes #86