From 51793d08a6d8d4d182c9f04aa06a4a55364be16c Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Sat, 9 Nov 2024 17:49:45 +0100 Subject: [PATCH] Refactor variable management methods to use async naming Updated method names in `IWorkflowInstanceVariableManager` and `WorkflowInstanceVariableManager` to use the `Async` suffix for consistency. This change improves code readability and aligns with async programming conventions. --- .../WorkflowInstances/Variables/List/Endpoint.cs | 2 +- .../WorkflowInstances/Variables/Post/Endpoint.cs | 2 +- .../Contracts/IWorkflowInstanceVariableManager.cs | 8 ++++---- .../Services/WorkflowInstanceVariableManager.cs | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Variables/List/Endpoint.cs b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Variables/List/Endpoint.cs index 829b816745..eec16fa804 100644 --- a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Variables/List/Endpoint.cs +++ b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Variables/List/Endpoint.cs @@ -27,7 +27,7 @@ public override async Task HandleAsync(CancellationToken cancellationToken) return; } - var variables = await workflowInstanceVariableManager.GetVariables(workflowInstanceId, cancellationToken).ToList(); + var variables = await workflowInstanceVariableManager.GetVariablesAsync(workflowInstanceId, cancellationToken).ToList(); var variableModels = variables.Select(x => new ResolvedVariableModel(x.Variable.Id, x.Variable.Name, x.Value)).ToList(); var response = new ListResponse(variableModels); await SendOkAsync(response, cancellationToken); diff --git a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Variables/Post/Endpoint.cs b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Variables/Post/Endpoint.cs index 7ff6df1ee0..66683aa15e 100644 --- a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Variables/Post/Endpoint.cs +++ b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowInstances/Variables/Post/Endpoint.cs @@ -27,7 +27,7 @@ public override async Task HandleAsync(Request request, CancellationToken cancel return; } - var resolvedVariables = await workflowInstanceVariableManager.SetVariables(workflowInstanceId, request.Variables, cancellationToken).ToList(); + var resolvedVariables = await workflowInstanceVariableManager.SetVariablesAsync(workflowInstanceId, request.Variables, cancellationToken).ToList(); var variableModels = resolvedVariables.Select(x => new ResolvedVariableModel(x.Variable.Id, x.Variable.Name, x.Value)).ToList(); var response = new ListResponse(variableModels); await SendOkAsync(response, cancellationToken); diff --git a/src/modules/Elsa.Workflows.Management/Contracts/IWorkflowInstanceVariableManager.cs b/src/modules/Elsa.Workflows.Management/Contracts/IWorkflowInstanceVariableManager.cs index 7f65f83743..965e769fe9 100644 --- a/src/modules/Elsa.Workflows.Management/Contracts/IWorkflowInstanceVariableManager.cs +++ b/src/modules/Elsa.Workflows.Management/Contracts/IWorkflowInstanceVariableManager.cs @@ -8,7 +8,7 @@ public interface IWorkflowInstanceVariableManager /// The ID of the workflow instance. /// The cancellation token to cancel the operation. /// A task that represents the asynchronous operation. The task result contains a collection of instances. - Task> GetVariables(string workflowInstanceId, CancellationToken cancellationToken = default); + Task> GetVariablesAsync(string workflowInstanceId, CancellationToken cancellationToken = default); /// /// Retrieves all variables from the specified . @@ -16,7 +16,7 @@ public interface IWorkflowInstanceVariableManager /// The context of the workflow execution. /// The cancellation token to cancel the operation. /// A task that represents the asynchronous operation. The task result contains a collection of instances. - Task> GetVariables(WorkflowExecutionContext workflowExecutionContext, CancellationToken cancellationToken = default); + Task> GetVariablesAsync(WorkflowExecutionContext workflowExecutionContext, CancellationToken cancellationToken = default); /// /// Sets the specified variables in the specified workflow instance. @@ -25,7 +25,7 @@ public interface IWorkflowInstanceVariableManager /// The collection of variables to set. /// The cancellation token to cancel the operation. /// A complete list of resolved variables. - Task> SetVariables(string workflowInstanceId, IEnumerable variables, CancellationToken cancellationToken = default); + Task> SetVariablesAsync(string workflowInstanceId, IEnumerable variables, CancellationToken cancellationToken = default); /// /// Sets the specified variables in the given . @@ -34,5 +34,5 @@ public interface IWorkflowInstanceVariableManager /// The collection of variables to set. /// The cancellation token to cancel the operation. /// A complete list of resolved variables. - Task> SetVariables(WorkflowExecutionContext workflowExecutionContext, IEnumerable variables, CancellationToken cancellationToken = default); + Task> SetVariablesAsync(WorkflowExecutionContext workflowExecutionContext, IEnumerable variables, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Management/Services/WorkflowInstanceVariableManager.cs b/src/modules/Elsa.Workflows.Management/Services/WorkflowInstanceVariableManager.cs index 45d364ceaf..9fae974f41 100644 --- a/src/modules/Elsa.Workflows.Management/Services/WorkflowInstanceVariableManager.cs +++ b/src/modules/Elsa.Workflows.Management/Services/WorkflowInstanceVariableManager.cs @@ -7,19 +7,19 @@ public class WorkflowInstanceVariableManager( IWorkflowInstanceVariableReader variableReader, IWorkflowInstanceVariableWriter variableWriter) : IWorkflowInstanceVariableManager { - public async Task> GetVariables(string workflowInstanceId, CancellationToken cancellationToken = default) + public async Task> GetVariablesAsync(string workflowInstanceId, CancellationToken cancellationToken = default) { var workflowExecutionContext = await GetWorkflowExecutionContextAsync(workflowInstanceId, cancellationToken); if (workflowExecutionContext == null) return []; return await variableReader.GetVariables(workflowExecutionContext, cancellationToken); } - public Task> GetVariables(WorkflowExecutionContext workflowExecutionContext, CancellationToken cancellationToken = default) + public Task> GetVariablesAsync(WorkflowExecutionContext workflowExecutionContext, CancellationToken cancellationToken = default) { return variableReader.GetVariables(workflowExecutionContext, cancellationToken); } - public async Task> SetVariables(string workflowInstanceId, IEnumerable variables, CancellationToken cancellationToken = default) + public async Task> SetVariablesAsync(string workflowInstanceId, IEnumerable variables, CancellationToken cancellationToken = default) { var workflowExecutionContext = await GetWorkflowExecutionContextAsync(workflowInstanceId, cancellationToken); if (workflowExecutionContext == null) return []; @@ -28,7 +28,7 @@ public async Task> SetVariables(string workflowIns return resolvedVariables; } - public Task> SetVariables(WorkflowExecutionContext workflowExecutionContext, IEnumerable variables, CancellationToken cancellationToken = default) + public Task> SetVariablesAsync(WorkflowExecutionContext workflowExecutionContext, IEnumerable variables, CancellationToken cancellationToken = default) { return variableWriter.SetVariables(workflowExecutionContext, variables, cancellationToken); }