Skip to content

Commit

Permalink
Refactor variable management methods to use async naming
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sfmskywalker committed Nov 9, 2024
1 parent 55b9361 commit 51793d0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ResolvedVariableModel>(variableModels);
await SendOkAsync(response, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ResolvedVariableModel>(variableModels);
await SendOkAsync(response, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ public interface IWorkflowInstanceVariableManager
/// <param name="workflowInstanceId">The ID of the workflow instance.</param>
/// <param name="cancellationToken">The cancellation token to cancel the operation.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains a collection of <see cref="ResolvedVariable"/> instances.</returns>
Task<IEnumerable<ResolvedVariable>> GetVariables(string workflowInstanceId, CancellationToken cancellationToken = default);
Task<IEnumerable<ResolvedVariable>> GetVariablesAsync(string workflowInstanceId, CancellationToken cancellationToken = default);

/// <summary>
/// Retrieves all variables from the specified <see cref="WorkflowExecutionContext"/>.
/// </summary>
/// <param name="workflowExecutionContext">The context of the workflow execution.</param>
/// <param name="cancellationToken">The cancellation token to cancel the operation.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains a collection of <see cref="ResolvedVariable"/> instances.</returns>
Task<IEnumerable<ResolvedVariable>> GetVariables(WorkflowExecutionContext workflowExecutionContext, CancellationToken cancellationToken = default);
Task<IEnumerable<ResolvedVariable>> GetVariablesAsync(WorkflowExecutionContext workflowExecutionContext, CancellationToken cancellationToken = default);

/// <summary>
/// Sets the specified variables in the specified workflow instance.
Expand All @@ -25,7 +25,7 @@ public interface IWorkflowInstanceVariableManager
/// <param name="variables">The collection of variables to set.</param>
/// <param name="cancellationToken">The cancellation token to cancel the operation.</param>
/// <returns>A complete list of resolved variables.</returns>
Task<IEnumerable<ResolvedVariable>> SetVariables(string workflowInstanceId, IEnumerable<VariableUpdateValue> variables, CancellationToken cancellationToken = default);
Task<IEnumerable<ResolvedVariable>> SetVariablesAsync(string workflowInstanceId, IEnumerable<VariableUpdateValue> variables, CancellationToken cancellationToken = default);

/// <summary>
/// Sets the specified variables in the given <see cref="WorkflowExecutionContext"/>.
Expand All @@ -34,5 +34,5 @@ public interface IWorkflowInstanceVariableManager
/// <param name="variables">The collection of variables to set.</param>
/// <param name="cancellationToken">The cancellation token to cancel the operation.</param>
/// <returns>A complete list of resolved variables.</returns>
Task<IEnumerable<ResolvedVariable>> SetVariables(WorkflowExecutionContext workflowExecutionContext, IEnumerable<VariableUpdateValue> variables, CancellationToken cancellationToken = default);
Task<IEnumerable<ResolvedVariable>> SetVariablesAsync(WorkflowExecutionContext workflowExecutionContext, IEnumerable<VariableUpdateValue> variables, CancellationToken cancellationToken = default);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ public class WorkflowInstanceVariableManager(
IWorkflowInstanceVariableReader variableReader,
IWorkflowInstanceVariableWriter variableWriter) : IWorkflowInstanceVariableManager
{
public async Task<IEnumerable<ResolvedVariable>> GetVariables(string workflowInstanceId, CancellationToken cancellationToken = default)
public async Task<IEnumerable<ResolvedVariable>> GetVariablesAsync(string workflowInstanceId, CancellationToken cancellationToken = default)
{
var workflowExecutionContext = await GetWorkflowExecutionContextAsync(workflowInstanceId, cancellationToken);
if (workflowExecutionContext == null) return [];
return await variableReader.GetVariables(workflowExecutionContext, cancellationToken);
}

public Task<IEnumerable<ResolvedVariable>> GetVariables(WorkflowExecutionContext workflowExecutionContext, CancellationToken cancellationToken = default)
public Task<IEnumerable<ResolvedVariable>> GetVariablesAsync(WorkflowExecutionContext workflowExecutionContext, CancellationToken cancellationToken = default)
{
return variableReader.GetVariables(workflowExecutionContext, cancellationToken);
}

public async Task<IEnumerable<ResolvedVariable>> SetVariables(string workflowInstanceId, IEnumerable<VariableUpdateValue> variables, CancellationToken cancellationToken = default)
public async Task<IEnumerable<ResolvedVariable>> SetVariablesAsync(string workflowInstanceId, IEnumerable<VariableUpdateValue> variables, CancellationToken cancellationToken = default)
{
var workflowExecutionContext = await GetWorkflowExecutionContextAsync(workflowInstanceId, cancellationToken);
if (workflowExecutionContext == null) return [];
Expand All @@ -28,7 +28,7 @@ public async Task<IEnumerable<ResolvedVariable>> SetVariables(string workflowIns
return resolvedVariables;
}

public Task<IEnumerable<ResolvedVariable>> SetVariables(WorkflowExecutionContext workflowExecutionContext, IEnumerable<VariableUpdateValue> variables, CancellationToken cancellationToken = default)
public Task<IEnumerable<ResolvedVariable>> SetVariablesAsync(WorkflowExecutionContext workflowExecutionContext, IEnumerable<VariableUpdateValue> variables, CancellationToken cancellationToken = default)
{
return variableWriter.SetVariables(workflowExecutionContext, variables, cancellationToken);
}
Expand Down

0 comments on commit 51793d0

Please sign in to comment.