Support for CancellationToken in IAsyncFlow
TheFo2sh opened this issue · comments
Title:
Support for CancellationToken in IAsyncFlow
Description:
Problem:
Currently, our IAsyncFlow
interface does not support CancellationToken
. This means that if a delete request comes in while ProcessAsync
is still running, the process won't be cancelled immediately.
Detailed Explanation:
When processing long-running jobs, it's crucial to have the ability to cancel them if needed. Not having cancellation support can lead to wasted resources, especially if the result of the job is no longer required (e.g., if a delete request has been received).
Proposed Solution:
Introduce a CancellationToken
parameter to the ProcessAsync
method in the IAsyncFlow
interface. This would enable any implementing class to respect cancellation requests.
Task<TResult> ProcessAsync(TRequest request, CancellationToken cancellationToken);
Additionally, when handling the Delete request on the API side, signal the cancellation token to attempt to halt the ongoing operation.
Impact:
Existing implementations of the IAsyncFlow
interface would need to be updated to handle the new parameter. Documentation would need to be updated as well to guide users on how to use the cancellation token properly.