Skip to content

Commit 9531d65

Browse files
committed
client side no status check
1 parent fe00211 commit 9531d65

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

src/Abstractions/TaskOptions.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,9 @@ public record StartOrchestrationOptions(string? InstanceId = null, DateTimeOffse
137137

138138
/// <summary>
139139
/// Gets the orchestration runtime statuses that should be considered for deduplication.
140-
/// If an orchestration instance with the same instance ID already exists and is in one of these statuses,
141-
/// the creation will throw an exception instead of creating a new instance.
142-
/// This enables idempotent orchestration creation.
143140
/// </summary>
144141
/// <remarks>
145142
/// The status names should match the values from <see cref="Microsoft.DurableTask.Client.OrchestrationRuntimeStatus"/> enum
146-
/// (e.g., "Completed", "Failed", "Terminated", "Canceled").
147143
/// For type-safe usage, use extension methods from <see cref="StartOrchestrationOptionsExtensions"/>.
148144
/// </remarks>
149145
public IReadOnlyList<string>? DedupeStatuses { get; init; }

src/Client/Core/StartOrchestrationOptionsExtensions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ namespace Microsoft.DurableTask.Client;
99
public static class StartOrchestrationOptionsExtensions
1010
{
1111
/// <summary>
12-
/// Gets the terminal orchestration runtime statuses that are valid for deduplication.
13-
/// These are the statuses that can be used to prevent replacement of an existing orchestration instance.
12+
/// Gets the terminal orchestration runtime statuses commonly used for deduplication.
13+
/// These are typically the statuses used to prevent replacement of an existing orchestration instance.
14+
/// Note: Any <see cref="OrchestrationRuntimeStatus"/> value can be used for deduplication;
15+
/// this collection is provided for convenience and reference only.
1416
/// </summary>
1517
public static readonly OrchestrationRuntimeStatus[] ValidDedupeStatuses = new[]
1618
{

src/Client/Grpc/GrpcDurableTaskClient.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ public override async Task<string> ScheduleNewOrchestrationInstanceAsync(
134134
{
135135
if (!System.Enum.TryParse<OrchestrationRuntimeStatus>(s, ignoreCase: true, out OrchestrationRuntimeStatus status))
136136
{
137-
string validStatuses = string.Join(", ", StartOrchestrationOptionsExtensions.ValidDedupeStatuses.Select(ts => ts.ToString()));
137+
string validStatuses = string.Join(", ", System.Enum.GetNames(typeof(OrchestrationRuntimeStatus)));
138138
throw new ArgumentException(
139-
$"Invalid orchestration runtime status for deduplication: '{s}'. Valid statuses for deduplication are: {validStatuses}",
139+
$"Invalid orchestration runtime status: '{s}' for deduplication. Valid values are: {validStatuses}",
140140
nameof(options.DedupeStatuses));
141141
}
142142

@@ -146,9 +146,7 @@ public override async Task<string> ScheduleNewOrchestrationInstanceAsync(
146146
P.OrchestrationIdReusePolicy policy = new();
147147

148148
// The policy uses "replaceableStatus" - these are statuses that CAN be replaced
149-
// dedupeStatuses are statuses that should NOT be replaced (should throw exception)
150-
// So we add terminal statuses that are NOT in dedupeStatuses to replaceableStatus
151-
// This matches the logic in AAPT-DTMB ProtoUtils.Convert
149+
// dedupeStatuses are statuses that should NOT be replaced
152150
foreach (OrchestrationRuntimeStatus terminalStatus in StartOrchestrationOptionsExtensions.ValidDedupeStatuses.Where(ts => !dedupeStatuses.Contains(ts)))
153151
{
154152
policy.ReplaceableStatus.Add(terminalStatus.ToGrpcStatus());

src/Client/OrchestrationServiceClientShim/ShimDurableTaskClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ public override async Task<string> ScheduleNewOrchestrationInstanceAsync(
201201
{
202202
if (!Enum.TryParse<OrchestrationRuntimeStatus>(s, ignoreCase: true, out var status))
203203
{
204-
var validStatuses = string.Join(", ", StartOrchestrationOptionsExtensions.ValidDedupeStatuses.Select(ts => ts.ToString()));
204+
var validStatuses = string.Join(", ", Enum.GetNames(typeof(OrchestrationRuntimeStatus)));
205205
throw new ArgumentException(
206-
$"Invalid orchestration runtime status for deduplication: '{s}'. Valid statuses for deduplication are: {validStatuses}",
206+
$"Invalid orchestration runtime status: '{s}' for deduplication. Valid values are: {validStatuses}",
207207
nameof(options.DedupeStatuses));
208208
}
209209
return status.ConvertToCore();

0 commit comments

Comments
 (0)