From 0ec913b95e0e6b0a287a917558d859d4a70ce7bf Mon Sep 17 00:00:00 2001 From: TekH Date: Thu, 27 Nov 2025 11:05:21 +0100 Subject: [PATCH] Refactor to support batch action invocation Replaced `InvokeRecAction` with `InvokeBatchRecAction` in `ActionController` to transition from single-action to batch-action invocation. Removed `InvokeRecActionCommand.cs`, which previously handled individual action invocations. Introduced `InvokeBatchRecActionsCommand.cs` to handle batch processing with similar concurrency control logic using a semaphore. This redesign improves scalability and aligns with updated business requirements while maintaining compatibility with the existing application structure. --- src/ReC.API/Controllers/ActionController.cs | 2 +- ...ionCommand.cs => InvokeBatchRecActionsCommand.cs} | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) rename src/ReC.Application/RecActions/Commands/{InvokeRecActionCommand.cs => InvokeBatchRecActionsCommand.cs} (73%) diff --git a/src/ReC.API/Controllers/ActionController.cs b/src/ReC.API/Controllers/ActionController.cs index 6070956..e1055b7 100644 --- a/src/ReC.API/Controllers/ActionController.cs +++ b/src/ReC.API/Controllers/ActionController.cs @@ -11,7 +11,7 @@ public class ActionController(IMediator mediator) : ControllerBase [HttpPost("{profileId}")] public async Task Invoke([FromRoute] int profileId) { - await mediator.InvokeRecAction(profileId); + await mediator.InvokeBatchRecAction(profileId); return Accepted(); } } \ No newline at end of file diff --git a/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs b/src/ReC.Application/RecActions/Commands/InvokeBatchRecActionsCommand.cs similarity index 73% rename from src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs rename to src/ReC.Application/RecActions/Commands/InvokeBatchRecActionsCommand.cs index de3dc62..e993fea 100644 --- a/src/ReC.Application/RecActions/Commands/InvokeRecActionCommand.cs +++ b/src/ReC.Application/RecActions/Commands/InvokeBatchRecActionsCommand.cs @@ -4,17 +4,17 @@ using ReC.Application.RecActions.Queries; namespace ReC.Application.RecActions.Commands; -public record InvokeRecActionCommand : ReadRecActionQueryBase, IRequest; +public record InvokeBatchRecActionsCommand : ReadRecActionQueryBase, IRequest; -public static class InvokeRecActionCommandExtensions +public static class InvokeBatchRecActionsCommandExtensions { - public static Task InvokeRecAction(this ISender sender, int profileId) - => sender.Send(new InvokeRecActionCommand { ProfileId = profileId }); + public static Task InvokeBatchRecAction(this ISender sender, int profileId) + => sender.Send(new InvokeBatchRecActionsCommand { ProfileId = profileId }); } -public class InvokeRecActionCommandHandler(ISender sender, IHttpClientFactory clientFactory, ILogger? logger = null) : IRequestHandler +public class InvokeRecActionsCommandHandler(ISender sender, IHttpClientFactory clientFactory, ILogger? logger = null) : IRequestHandler { - public async Task Handle(InvokeRecActionCommand request, CancellationToken cancel) + public async Task Handle(InvokeBatchRecActionsCommand request, CancellationToken cancel) { var actions = await sender.Send(request.ToReadQuery(), cancel);