| | | 1 | | using Elsa.Abstractions; |
| | | 2 | | using Elsa.Workflows.Runtime; |
| | | 3 | | using Elsa.Workflows.Runtime.Requests; |
| | | 4 | | using Elsa.Workflows.Runtime.Responses; |
| | | 5 | | using JetBrains.Annotations; |
| | | 6 | | |
| | | 7 | | namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Refresh; |
| | | 8 | | |
| | | 9 | | [PublicAPI] |
| | 1 | 10 | | internal class Refresh(IWorkflowDefinitionsRefresher workflowDefinitionsRefresher) : ElsaEndpoint<Request> |
| | | 11 | | { |
| | | 12 | | private const int BatchSize = 10; |
| | | 13 | | |
| | | 14 | | public override void Configure() |
| | | 15 | | { |
| | 1 | 16 | | Post("/actions/workflow-definitions/refresh"); |
| | 1 | 17 | | ConfigurePermissions("actions:workflow-definitions:refresh"); |
| | 1 | 18 | | } |
| | | 19 | | |
| | | 20 | | public override async Task HandleAsync(Request request, CancellationToken cancellationToken) |
| | | 21 | | { |
| | 0 | 22 | | var result = await RefreshWorkflowDefinitionsAsync(request.DefinitionIds, cancellationToken); |
| | 0 | 23 | | await Send.OkAsync(new Response(result.Refreshed, result.NotFound), cancellationToken); |
| | 0 | 24 | | } |
| | | 25 | | |
| | | 26 | | private async Task<RefreshWorkflowDefinitionsResponse> RefreshWorkflowDefinitionsAsync(ICollection<string>? definiti |
| | | 27 | | { |
| | 0 | 28 | | var request = new RefreshWorkflowDefinitionsRequest(definitionIds, BatchSize); |
| | 0 | 29 | | return await workflowDefinitionsRefresher.RefreshWorkflowDefinitionsAsync(request, cancellationToken); |
| | 0 | 30 | | } |
| | | 31 | | } |