TheFo2sh / AsyncFlow

Integrate asynchronous job flows with ease in your .NET applications. AsyncFlow is designed for web applications that use a pattern where users call an invoke API, receive a job ID, and can then track and retrieve the job's results using separate endpoints.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

closed by commit
#4