From d97949d6f05bc0fd07c6e137de5b04155329dd27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Stenr=C3=B8jl?= Date: Tue, 17 Dec 2024 10:26:18 +0100 Subject: [PATCH] Named record for ActivityInput --- .../EnqueueMessagesActivity_Brs_026_V1.cs | 8 ++++---- ...EnqueueRejectMessageActivity_Brs_026_V1.cs | 8 ++++---- ...rformAsyncValidationActivity_Brs_026_V1.cs | 6 +++--- .../StartOrchestrationActivity_Brs_026_V1.cs | 11 ++++++---- ...rminateOrchestrationActivity_Brs_026_V1.cs | 6 +++--- .../TerminateStepActivity_Brs_026_V1.cs | 6 +++--- ...on_RequestCalculatedEnergyTimeSeries_V1.cs | 20 +++++++++++-------- 7 files changed, 36 insertions(+), 29 deletions(-) diff --git a/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/EnqueueMessagesActivity_Brs_026_V1.cs b/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/EnqueueMessagesActivity_Brs_026_V1.cs index f6bcb9a4..a758bac1 100644 --- a/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/EnqueueMessagesActivity_Brs_026_V1.cs +++ b/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/EnqueueMessagesActivity_Brs_026_V1.cs @@ -31,7 +31,7 @@ internal class EnqueueMessagesActivity_Brs_026_V1( private readonly IClock _clock = clock; private readonly IOrchestrationInstanceProgressRepository _progressRepository = progressRepository; - public static Task RunActivity(TaskOrchestrationContext context, EnqueueMessagesActivityInput activityInput, TaskOptions options) + public static Task RunActivity(TaskOrchestrationContext context, ActivityInput activityInput, TaskOptions options) { return context.CallActivityAsync( nameof(EnqueueMessagesActivity_Brs_026_V1), @@ -41,7 +41,7 @@ public static Task RunActivity(TaskOrchestrationContext context, EnqueueMessages [Function(nameof(EnqueueMessagesActivity_Brs_026_V1))] public async Task Run( - [ActivityTrigger] EnqueueMessagesActivityInput input) + [ActivityTrigger] ActivityInput input) { var orchestrationInstance = await _progressRepository .GetAsync(input.InstanceId) @@ -54,13 +54,13 @@ public async Task Run( await EnqueueMessagesAsync(input).ConfigureAwait(false); } - private async Task EnqueueMessagesAsync(EnqueueMessagesActivityInput input) + private async Task EnqueueMessagesAsync(ActivityInput input) { // TODO: Enqueue message in EDI instead of delay await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false); } - public record EnqueueMessagesActivityInput( + public record ActivityInput( OrchestrationInstanceId InstanceId, RequestCalculatedEnergyTimeSeriesInputV1 RequestInput); } diff --git a/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/EnqueueRejectMessageActivity_Brs_026_V1.cs b/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/EnqueueRejectMessageActivity_Brs_026_V1.cs index f17dafe2..39b12ba2 100644 --- a/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/EnqueueRejectMessageActivity_Brs_026_V1.cs +++ b/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/EnqueueRejectMessageActivity_Brs_026_V1.cs @@ -30,7 +30,7 @@ internal class EnqueueRejectMessageActivity_Brs_026_V1( private readonly IClock _clock = clock; private readonly IOrchestrationInstanceProgressRepository _progressRepository = progressRepository; - public static Task RunActivity(TaskOrchestrationContext context, EnqueueRejectMessageActivityInput activityInput, TaskOptions options) + public static Task RunActivity(TaskOrchestrationContext context, ActivityInput activityInput, TaskOptions options) { return context.CallActivityAsync( nameof(EnqueueRejectMessageActivity_Brs_026_V1), @@ -40,7 +40,7 @@ public static Task RunActivity(TaskOrchestrationContext context, EnqueueRejectMe [Function(nameof(EnqueueRejectMessageActivity_Brs_026_V1))] public async Task Run( - [ActivityTrigger] EnqueueRejectMessageActivityInput input) + [ActivityTrigger] ActivityInput input) { var orchestrationInstance = await _progressRepository .GetAsync(input.InstanceId) @@ -54,13 +54,13 @@ public async Task Run( await EnqueueRejectMessageAsync(input).ConfigureAwait(false); } - private async Task EnqueueRejectMessageAsync(EnqueueRejectMessageActivityInput input) + private async Task EnqueueRejectMessageAsync(ActivityInput input) { // TODO: Enqueue message in EDI instead of delay await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false); } - public record EnqueueRejectMessageActivityInput( + public record ActivityInput( OrchestrationInstanceId InstanceId, string ValidationError); } diff --git a/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/PerformAsyncValidationActivity_Brs_026_V1.cs b/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/PerformAsyncValidationActivity_Brs_026_V1.cs index ca6d6f3b..ae2eff08 100644 --- a/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/PerformAsyncValidationActivity_Brs_026_V1.cs +++ b/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/PerformAsyncValidationActivity_Brs_026_V1.cs @@ -31,7 +31,7 @@ internal class PerformAsyncValidationActivity_Brs_026_V1( private readonly IClock _clock = clock; private readonly IOrchestrationInstanceProgressRepository _progressRepository = progressRepository; - public static Task RunActivity(TaskOrchestrationContext context, AsyncValidationActivityInput activityInput, TaskOptions options) + public static Task RunActivity(TaskOrchestrationContext context, ActivityInput activityInput, TaskOptions options) { return context.CallActivityAsync( nameof(PerformAsyncValidationActivity_Brs_026_V1), @@ -41,7 +41,7 @@ public static Task RunActivity(TaskOrchestrationContext context, AsyncVali [Function(nameof(PerformAsyncValidationActivity_Brs_026_V1))] public async Task Run( - [ActivityTrigger] AsyncValidationActivityInput input) + [ActivityTrigger] ActivityInput input) { var orchestrationInstance = await _progressRepository .GetAsync(input.InstanceId) @@ -64,7 +64,7 @@ private async Task PerformAsyncValidationAsync(RequestCalculatedEnergyTime return true; } - public record AsyncValidationActivityInput( + public record ActivityInput( OrchestrationInstanceId InstanceId, RequestCalculatedEnergyTimeSeriesInputV1 RequestInput); } diff --git a/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/StartOrchestrationActivity_Brs_026_V1.cs b/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/StartOrchestrationActivity_Brs_026_V1.cs index ba380eec..0b8a65db 100644 --- a/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/StartOrchestrationActivity_Brs_026_V1.cs +++ b/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/StartOrchestrationActivity_Brs_026_V1.cs @@ -30,23 +30,26 @@ internal class StartOrchestrationActivity_Brs_026_V1( private readonly IClock _clock = clock; private readonly IOrchestrationInstanceProgressRepository _progressRepository = progressRepository; - public static Task RunActivity(TaskOrchestrationContext context, OrchestrationInstanceId orchestrationId, TaskOptions options) + public static Task RunActivity(TaskOrchestrationContext context, ActivityInput input, TaskOptions options) { return context.CallActivityAsync( nameof(StartOrchestrationActivity_Brs_026_V1), - orchestrationId, + input, options); } [Function(nameof(StartOrchestrationActivity_Brs_026_V1))] public async Task Run( - [ActivityTrigger] OrchestrationInstanceId orchestrationInstanceId) + [ActivityTrigger] ActivityInput input) { var orchestrationInstance = await _progressRepository - .GetAsync(orchestrationInstanceId) + .GetAsync(input.InstanceId) .ConfigureAwait(false); orchestrationInstance.Lifecycle.TransitionToRunning(_clock); await _progressRepository.UnitOfWork.CommitAsync().ConfigureAwait(false); } + + public record ActivityInput( + OrchestrationInstanceId InstanceId); } diff --git a/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/TerminateOrchestrationActivity_Brs_026_V1.cs b/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/TerminateOrchestrationActivity_Brs_026_V1.cs index 9de99584..a4fe4bc4 100644 --- a/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/TerminateOrchestrationActivity_Brs_026_V1.cs +++ b/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/TerminateOrchestrationActivity_Brs_026_V1.cs @@ -30,7 +30,7 @@ internal class TerminateOrchestrationActivity_Brs_026_V1( private readonly IClock _clock = clock; private readonly IOrchestrationInstanceProgressRepository _progressRepository = progressRepository; - public static Task RunActivity(TaskOrchestrationContext context, TerminateOrchestrationActivityInput input, TaskOptions options) + public static Task RunActivity(TaskOrchestrationContext context, ActivityInput input, TaskOptions options) { return context.CallActivityAsync( nameof(TerminateOrchestrationActivity_Brs_026_V1), @@ -40,7 +40,7 @@ public static Task RunActivity(TaskOrchestrationContext context, TerminateOrches [Function(nameof(TerminateOrchestrationActivity_Brs_026_V1))] public async Task Run( - [ActivityTrigger] TerminateOrchestrationActivityInput input) + [ActivityTrigger] ActivityInput input) { var orchestrationInstance = await _progressRepository .GetAsync(input.InstanceId) @@ -64,7 +64,7 @@ public async Task Run( await _progressRepository.UnitOfWork.CommitAsync().ConfigureAwait(false); } - public record TerminateOrchestrationActivityInput( + public record ActivityInput( OrchestrationInstanceId InstanceId, OrchestrationInstanceTerminationStates TerminationState); } diff --git a/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/TerminateStepActivity_Brs_026_V1.cs b/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/TerminateStepActivity_Brs_026_V1.cs index a87dc13e..d2e5d0b9 100644 --- a/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/TerminateStepActivity_Brs_026_V1.cs +++ b/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Activities/TerminateStepActivity_Brs_026_V1.cs @@ -30,7 +30,7 @@ internal class TerminateStepActivity_Brs_026_V1( private readonly IClock _clock = clock; private readonly IOrchestrationInstanceProgressRepository _progressRepository = progressRepository; - public static Task RunActivity(TaskOrchestrationContext context, TerminateStepActivityInput input, TaskOptions options) + public static Task RunActivity(TaskOrchestrationContext context, ActivityInput input, TaskOptions options) { return context.CallActivityAsync( nameof(TerminateStepActivity_Brs_026_V1), @@ -40,7 +40,7 @@ public static Task RunActivity(TaskOrchestrationContext context, TerminateStepAc [Function(nameof(TerminateStepActivity_Brs_026_V1))] public async Task Run( - [ActivityTrigger] TerminateStepActivityInput input) + [ActivityTrigger] ActivityInput input) { var orchestrationInstance = await _progressRepository .GetAsync(input.InstanceId) @@ -54,7 +54,7 @@ public async Task Run( await _progressRepository.UnitOfWork.CommitAsync().ConfigureAwait(false); } - public record TerminateStepActivityInput( + public record ActivityInput( OrchestrationInstanceId InstanceId, int StepSequence, OrchestrationStepTerminationStates TerminationState); diff --git a/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Orchestration_RequestCalculatedEnergyTimeSeries_V1.cs b/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Orchestration_RequestCalculatedEnergyTimeSeries_V1.cs index c29339ee..7f275d0e 100644 --- a/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Orchestration_RequestCalculatedEnergyTimeSeries_V1.cs +++ b/source/ProcessManager.Orchestrations/Processes/BRS_026/V1/Orchestration_RequestCalculatedEnergyTimeSeries_V1.cs @@ -50,7 +50,11 @@ public async Task Run( var defaultRetryOptions = CreateDefaultRetryOptions(); // Set orchestration lifecycle to running - await StartOrchestrationActivity_Brs_026_V1.RunActivity(context, instanceId, defaultRetryOptions); + await StartOrchestrationActivity_Brs_026_V1.RunActivity( + context, + new StartOrchestrationActivity_Brs_026_V1.ActivityInput( + instanceId), + defaultRetryOptions); var isValid = await PerformAsyncValidation(context, instanceId, input, defaultRetryOptions); @@ -58,7 +62,7 @@ public async Task Run( { await EnqueueMessagesActivity_Brs_026_V1.RunActivity( context, - new EnqueueMessagesActivity_Brs_026_V1.EnqueueMessagesActivityInput( + new EnqueueMessagesActivity_Brs_026_V1.ActivityInput( instanceId, input), defaultRetryOptions); @@ -67,7 +71,7 @@ await EnqueueMessagesActivity_Brs_026_V1.RunActivity( { await EnqueueRejectMessageActivity_Brs_026_V1.RunActivity( context, - new EnqueueRejectMessageActivity_Brs_026_V1.EnqueueRejectMessageActivityInput( + new EnqueueRejectMessageActivity_Brs_026_V1.ActivityInput( instanceId, "Validation error"), defaultRetryOptions); @@ -80,7 +84,7 @@ await EnqueueRejectMessageActivity_Brs_026_V1.RunActivity( : OrchestrationStepTerminationStates.Failed; await TerminateStepActivity_Brs_026_V1.RunActivity( context, - new TerminateStepActivity_Brs_026_V1.TerminateStepActivityInput( + new TerminateStepActivity_Brs_026_V1.ActivityInput( instanceId, EnqueueMessagesStepSequence, enqueueMessagesTerminationState), @@ -96,7 +100,7 @@ await TerminateStepActivity_Brs_026_V1.RunActivity( await TerminateOrchestrationActivity_Brs_026_V1.RunActivity( context, - new TerminateOrchestrationActivity_Brs_026_V1.TerminateOrchestrationActivityInput( + new TerminateOrchestrationActivity_Brs_026_V1.ActivityInput( instanceId, OrchestrationInstanceTerminationStates.Failed), defaultRetryOptions); @@ -106,7 +110,7 @@ await TerminateOrchestrationActivity_Brs_026_V1.RunActivity( await TerminateOrchestrationActivity_Brs_026_V1.RunActivity( context, - new TerminateOrchestrationActivity_Brs_026_V1.TerminateOrchestrationActivityInput( + new TerminateOrchestrationActivity_Brs_026_V1.ActivityInput( instanceId, OrchestrationInstanceTerminationStates.Succeeded), defaultRetryOptions); @@ -131,7 +135,7 @@ private async Task PerformAsyncValidation( { var isValid = await PerformAsyncValidationActivity_Brs_026_V1.RunActivity( context, - new PerformAsyncValidationActivity_Brs_026_V1.AsyncValidationActivityInput( + new PerformAsyncValidationActivity_Brs_026_V1.ActivityInput( instanceId, input), retryOptions); @@ -141,7 +145,7 @@ private async Task PerformAsyncValidation( : OrchestrationStepTerminationStates.Failed; await TerminateStepActivity_Brs_026_V1.RunActivity( context, - new TerminateStepActivity_Brs_026_V1.TerminateStepActivityInput( + new TerminateStepActivity_Brs_026_V1.ActivityInput( instanceId, AsyncValidationStepSequence, asyncValidationTerminationState),