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.
This commit is contained in:
parent
6041d57948
commit
c34a87771d
@ -19,9 +19,9 @@ public class RecActionController(IMediator mediator) : ControllerBase
|
||||
}, cancel));
|
||||
|
||||
[HttpPost("{profileId}")]
|
||||
public async Task<IActionResult> Invoke([FromRoute] int profileId)
|
||||
public async Task<IActionResult> Invoke([FromRoute] int profileId, CancellationToken cancel)
|
||||
{
|
||||
await mediator.InvokeBatchRecAction(profileId);
|
||||
await mediator.InvokeBatchRecAction(profileId, cancel);
|
||||
return Accepted();
|
||||
}
|
||||
|
||||
|
||||
@ -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<InvokeRecActionsCommandHandler>? logger = null) : IRequestHandler<InvokeBatchRecActionsCommand>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user