Skip to content

Commit

Permalink
refac: Rename enum types to singular names (#86)
Browse files Browse the repository at this point in the history
* Refactor enums to use singular naming instead of plural

* Rename

* Bump version and update release notes

* Apply suggestions from code review

Co-authored-by: RasmusGraabaek <rasmus.graabaek@hotmail.com>

---------

Co-authored-by: RasmusGraabaek <rasmus.graabaek@hotmail.com>
  • Loading branch information
dstenroejl and RasmusGraabaek authored Jan 8, 2025
1 parent e92a37d commit 5d76eec
Show file tree
Hide file tree
Showing 61 changed files with 473 additions and 465 deletions.
4 changes: 4 additions & 0 deletions docs/ProcessManager.Client/ReleaseNotes/ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ProcessManager.Client Release Notes

## Version 0.16.0

- Renamed `enum` types to use singular naming to follow [Microsoft naming guidelines for naming enumerations](https://learn.microsoft.com/en-us/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces#naming-enumerations).

## Version 0.15.3

- No functional changes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ProcessManager.Orchestrations.Abstractions Release Notes

## Version 0.5.0

- Renamed `enum` types to use singular naming to follow [Microsoft naming guidelines for naming enumerations](https://learn.microsoft.com/en-us/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces#naming-enumerations).

## Version 0.4.3

- No functional changes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace Energinet.DataHub.ProcessManager.Abstractions.Api.Model.OrchestrationI
/// <param name="CustomState">Any custom state of the orchestration instance.</param>
public record OrchestrationInstanceDto(
Guid Id,
OrchestrationInstanceLifecycleStateDto Lifecycle,
OrchestrationInstanceLifecycleDto Lifecycle,
ExpandoObject ParameterValue,
IReadOnlyCollection<StepInstanceDto> Steps,
string CustomState);
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ namespace Energinet.DataHub.ProcessManager.Abstractions.Api.Model.OrchestrationI
/// <param name="QueuedAt">The time when the Process Manager has queued the orchestration instance for execution by Durable Functions (State => Queued).</param>
/// <param name="StartedAt">The time when the Process Manager was used from Durable Functions to transition the state to Running.</param>
/// <param name="TerminatedAt">The time when the Process Manager was used from Durable Functions to transition the state to Terminated.</param>
public record OrchestrationInstanceLifecycleStateDto(
public record OrchestrationInstanceLifecycleDto(
IOperatingIdentityDto CreatedBy,
OrchestrationInstanceLifecycleStates State,
OrchestrationInstanceTerminationStates? TerminationState,
OrchestrationInstanceLifecycleState State,
OrchestrationInstanceTerminationState? TerminationState,
IOperatingIdentityDto? CanceledBy,
DateTimeOffset CreatedAt,
DateTimeOffset? ScheduledToRunAt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Energinet.DataHub.ProcessManager.Abstractions.Api.Model.OrchestrationI
/// <summary>
/// High-level lifecycle states that all orchestration instances can go through.
/// </summary>
public enum OrchestrationInstanceLifecycleStates
public enum OrchestrationInstanceLifecycleState
{
/// <summary>
/// Created and waiting to be started.
Expand All @@ -36,12 +36,12 @@ public enum OrchestrationInstanceLifecycleStates

/// <summary>
/// A Durable Functions activity has transitioned the orchestration instance into terminated.
/// See <see cref="OrchestrationInstanceTerminationStates"/> for details.
/// See <see cref="OrchestrationInstanceTerminationState"/> for details.
/// </summary>
Terminated = 4,
}

public enum OrchestrationInstanceTerminationStates
public enum OrchestrationInstanceTerminationState
{
Succeeded = 1,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Energinet.DataHub.ProcessManager.Abstractions.Api.Model.OrchestrationI
/// <param name="CustomState">Any custom state of the step.</param>
public record StepInstanceDto(
Guid Id,
StepInstanceLifecycleStateDto Lifecycle,
StepInstanceLifecycleDto Lifecycle,
string Description,
int Sequence,
string CustomState);
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ namespace Energinet.DataHub.ProcessManager.Abstractions.Api.Model.OrchestrationI
/// <param name="TerminationState"></param>
/// <param name="StartedAt">The time when the Process Manager was used from Durable Functions to transition the state to Running.</param>
/// <param name="TerminatedAt">The time when the Process Manager was used from Durable Functions to transition the state to Terminated.</param>
public record StepInstanceLifecycleStateDto(
StepInstanceLifecycleStates State,
OrchestrationStepTerminationStates? TerminationState,
public record StepInstanceLifecycleDto(
StepInstanceLifecycleState State,
OrchestrationStepTerminationState? TerminationState,
DateTimeOffset? StartedAt,
DateTimeOffset? TerminatedAt);
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Energinet.DataHub.ProcessManager.Abstractions.Api.Model.OrchestrationI
/// <summary>
/// High-level lifecycle states that all orchestration steps can go through.
/// </summary>
public enum StepInstanceLifecycleStates
public enum StepInstanceLifecycleState
{
/// <summary>
/// Created and waiting to be started.
Expand All @@ -31,12 +31,12 @@ public enum StepInstanceLifecycleStates

/// <summary>
/// A Durable Functions activity has transitioned the orchestration step into terminated.
/// See <see cref="OrchestrationStepTerminationStates"/> for details.
/// See <see cref="OrchestrationStepTerminationState"/> for details.
/// </summary>
Terminated = 3,
}

public enum OrchestrationStepTerminationStates
public enum OrchestrationStepTerminationState
{
Succeeded = 1,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public record OrchestrationInstanceTypedDto
/// <param name="customState">Any custom state of the orchestration instance.</param>
public OrchestrationInstanceTypedDto(
Guid id,
OrchestrationInstanceLifecycleStateDto lifecycle,
OrchestrationInstanceLifecycleDto lifecycle,
IReadOnlyCollection<StepInstanceDto> steps,
string customState)
{
Expand All @@ -44,9 +44,9 @@ public OrchestrationInstanceTypedDto(
public Guid Id { get; }

/// <summary>
/// The high-level lifecycle states that all orchestration instances can go through.
/// The high-level lifecycle that all orchestration instances can go through.
/// </summary>
public OrchestrationInstanceLifecycleStateDto Lifecycle { get; }
public OrchestrationInstanceLifecycleDto Lifecycle { get; }

/// <summary>
/// Workflow steps the orchestration instance is going through.
Expand Down Expand Up @@ -79,7 +79,7 @@ public record OrchestrationInstanceTypedDto<TInputParameterDto>
/// <param name="parameterValue">Contains the Durable Functions orchestration input parameter value.</param>
public OrchestrationInstanceTypedDto(
Guid id,
OrchestrationInstanceLifecycleStateDto lifecycle,
OrchestrationInstanceLifecycleDto lifecycle,
IReadOnlyCollection<StepInstanceDto> steps,
string customState,
TInputParameterDto parameterValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public SearchOrchestrationInstancesByNameQuery(
UserIdentityDto operatingIdentity,
string name,
int? version,
OrchestrationInstanceLifecycleStates? lifecycleState,
OrchestrationInstanceTerminationStates? terminationState,
OrchestrationInstanceLifecycleState? lifecycleState,
OrchestrationInstanceTerminationState? terminationState,
DateTimeOffset? startedAtOrLater,
DateTimeOffset? terminatedAtOrEarlier)
: base(operatingIdentity)
Expand Down Expand Up @@ -66,12 +66,12 @@ public SearchOrchestrationInstancesByNameQuery(
/// <summary>
/// Lifecycle states that orchestration instances can be in.
/// </summary>
public OrchestrationInstanceLifecycleStates? LifecycleState { get; }
public OrchestrationInstanceLifecycleState? LifecycleState { get; }

/// <summary>
/// Termination states that orchestration instances can be in.
/// </summary>
public OrchestrationInstanceTerminationStates? TerminationState { get; }
public OrchestrationInstanceTerminationState? TerminationState { get; }

/// <summary>
/// The time (or later) when the orchestration instances was transitioned to the Running state.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<PropertyGroup>
<PackageId>Energinet.DataHub.ProcessManager.Abstractions</PackageId>
<PackageVersion>0.15.3$(VersionSuffix)</PackageVersion>
<PackageVersion>0.16.0$(VersionSuffix)</PackageVersion>
<Title>DH3 Process Manager Abstractions library</Title>
<Company>Energinet-DataHub</Company>
<Authors>Energinet-DataHub</Authors>
Expand Down
2 changes: 1 addition & 1 deletion source/ProcessManager.Client/ProcessManager.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<PropertyGroup>
<PackageId>Energinet.DataHub.ProcessManager.Client</PackageId>
<PackageVersion>0.15.3$(VersionSuffix)</PackageVersion>
<PackageVersion>0.16.0$(VersionSuffix)</PackageVersion>
<Title>DH3 Process Manager Client library</Title>
<Company>Energinet-DataHub</Company>
<Authors>Energinet-DataHub</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public async Task GivenOrchestrationInstancesInDatabase_WhenSearchByNameAndLifec
}

// Act
var actual = await _sut.SearchAsync(existingOrchestrationDescriptionV1.UniqueName.Name, lifecycleState: OrchestrationInstanceLifecycleStates.Running);
var actual = await _sut.SearchAsync(existingOrchestrationDescriptionV1.UniqueName.Name, lifecycleState: OrchestrationInstanceLifecycleState.Running);

// Assert
actual.Should()
Expand Down Expand Up @@ -296,8 +296,8 @@ public async Task GivenOrchestrationInstancesInDatabase_WhenSearchByNameAndTermi
// Act
var actual = await _sut.SearchAsync(
existingOrchestrationDescriptionV1.UniqueName.Name,
lifecycleState: OrchestrationInstanceLifecycleStates.Terminated,
terminationState: OrchestrationInstanceTerminationStates.Succeeded);
lifecycleState: OrchestrationInstanceLifecycleState.Terminated,
terminationState: OrchestrationInstanceTerminationState.Succeeded);

// Assert
actual.Should()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public interface IOrchestrationInstanceQueries
Task<IReadOnlyCollection<OrchestrationInstance>> SearchAsync(
string name,
int? version,
OrchestrationInstanceLifecycleStates? lifecycleState,
OrchestrationInstanceTerminationStates? terminationState,
OrchestrationInstanceLifecycleState? lifecycleState,
OrchestrationInstanceTerminationState? terminationState,
Instant? startedAtOrLater,
Instant? terminatedAtOrEarlier);
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ internal interface IOrchestrationInstanceRepository
Task<IReadOnlyCollection<OrchestrationInstance>> SearchAsync(
string name,
int? version,
OrchestrationInstanceLifecycleStates? lifecycleState,
OrchestrationInstanceTerminationStates? terminationState,
OrchestrationInstanceLifecycleState? lifecycleState,
OrchestrationInstanceTerminationState? terminationState,
Instant? startedAtOrLater,
Instant? terminatedAtOrEarlier);
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private OrchestrationInstance(
Instant? runAt = default)
{
Id = new OrchestrationInstanceId(Guid.NewGuid());
Lifecycle = new OrchestrationInstanceLifecycleState(identity, clock, runAt);
Lifecycle = new OrchestrationInstanceLifecycle(identity, clock, runAt);
ParameterValue = new();
CustomState = new OrchestrationInstanceCustomState(string.Empty);

Expand All @@ -57,9 +57,9 @@ private OrchestrationInstance()
public OrchestrationInstanceId Id { get; }

/// <summary>
/// The high-level lifecycle states that all orchestration instances can go through.
/// The high-level lifecycle that all orchestration instances can go through.
/// </summary>
public OrchestrationInstanceLifecycleState Lifecycle { get; }
public OrchestrationInstanceLifecycle Lifecycle { get; }

/// <summary>
/// Contains the Durable Functions orchestration input parameter value.
Expand Down Expand Up @@ -127,7 +127,7 @@ public void TransitionStepToRunning(int sequence, IClock clock)
/// <param name="terminationState">The state of the termination step (Succeeded, failed etc.)</param>
/// <param name="clock"></param>
/// <exception cref="ArgumentOutOfRangeException">Thrown if a step with the given <paramref name="sequence"/> isn't found.</exception>
public void TransitionStepToTerminated(int sequence, OrchestrationStepTerminationStates terminationState, IClock clock)
public void TransitionStepToTerminated(int sequence, OrchestrationStepTerminationState terminationState, IClock clock)
{
var step = GetStep(sequence);
step.Lifecycle.TransitionToTerminated(clock, terminationState);
Expand Down Expand Up @@ -173,7 +173,7 @@ internal static OrchestrationInstance CreateFromDescription(

if (skipStepsBySequence.Contains(stepInstance.Sequence))
{
stepInstance.Lifecycle.TransitionToTerminated(clock, OrchestrationStepTerminationStates.Skipped);
stepInstance.Lifecycle.TransitionToTerminated(clock, OrchestrationStepTerminationState.Skipped);
}

orchestrationInstance._steps.Add(stepInstance);
Expand Down
Loading

0 comments on commit 5d76eec

Please sign in to comment.