From c34a87771d3b3ad4735115e864509430b23a019d Mon Sep 17 00:00:00 2001 From: TekH Date: Wed, 3 Dec 2025 11:31:38 +0100 Subject: [PATCH] Add CancellationToken support to RecAction methods Updated the `Invoke` method in `RecActionController` to accept a `CancellationToken` parameter, enabling cancellation handling during execution. Modified the `InvokeBatchRecAction` extension method in `InvokeBatchRecActionsCommandExtensions` to propagate the `CancellationToken` to the `sender.Send` method, ensuring cancellation support for batch action commands. --- src/ReC.API/Controllers/RecActionController.cs | 4 ++-- .../RecActions/Commands/InvokeBatchRecActionsCommand.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ReC.API/Controllers/RecActionController.cs b/src/ReC.API/Controllers/RecActionController.cs index a407991..736e58e 100644 --- a/src/ReC.API/Controllers/RecActionController.cs +++ b/src/ReC.API/Controllers/RecActionController.cs @@ -19,9 +19,9 @@ public class RecActionController(IMediator mediator) : ControllerBase }, cancel)); [HttpPost("{profileId}")] - public async Task Invoke([FromRoute] int profileId) + public async Task Invoke([FromRoute] int profileId, CancellationToken cancel) { - await mediator.InvokeBatchRecAction(profileId); + await mediator.InvokeBatchRecAction(profileId, cancel); return Accepted(); } diff --git a/src/ReC.Application/RecActions/Commands/InvokeBatchRecActionsCommand.cs b/src/ReC.Application/RecActions/Commands/InvokeBatchRecActionsCommand.cs index dd52538..fd12530 100644 --- a/src/ReC.Application/RecActions/Commands/InvokeBatchRecActionsCommand.cs +++ b/src/ReC.Application/RecActions/Commands/InvokeBatchRecActionsCommand.cs @@ -8,8 +8,8 @@ public record InvokeBatchRecActionsCommand : ReadRecActionQueryBase, IRequest; public static class InvokeBatchRecActionsCommandExtensions { - public static Task InvokeBatchRecAction(this ISender sender, int profileId) - => sender.Send(new InvokeBatchRecActionsCommand { ProfileId = profileId }); + public static Task InvokeBatchRecAction(this ISender sender, int profileId, CancellationToken cancel = default) + => sender.Send(new InvokeBatchRecActionsCommand { ProfileId = profileId }, cancel); } public class InvokeRecActionsCommandHandler(ISender sender, IHttpClientFactory clientFactory, ILogger? logger = null) : IRequestHandler