-
Notifications
You must be signed in to change notification settings - Fork 53
Changing the default dedupe statuses behavior #622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
8357e15
b434062
b8fc30b
c54e0cb
47bcb33
d8c26b3
64c3ba9
796f522
87a9bec
b6c7145
02b2427
dedcf9e
0b9a89e
098d9a3
c10c1bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| // Licensed under the MIT License. | ||
|
|
||
| using System.ComponentModel; | ||
| using DurableTask.Core.Exceptions; | ||
| using DurableTask.Core.History; | ||
| using Microsoft.DurableTask.Client.Entities; | ||
| using Microsoft.DurableTask.Internal; | ||
|
|
@@ -73,10 +74,14 @@ | |
| /// <remarks> | ||
| /// <para>All orchestrations must have a unique instance ID. You can provide an instance ID using the | ||
| /// <paramref name="options"/> parameter or you can omit this and a random instance ID will be | ||
| /// generated for you automatically. If an orchestration with the specified instance ID already exists and is in a | ||
| /// non-terminal state (Pending, Running, etc.), then this operation may fail silently. However, if an orchestration | ||
| /// instance with this ID already exists in a terminal state (Completed, Terminated, Failed, etc.) then the instance | ||
| /// may be recreated automatically, depending on the configuration of the backend instance store. | ||
| /// generated for you automatically. If an orchestration with the specified instance ID already exists and its status | ||
| /// is not in the <see cref="StartOrchestrationOptions.DedupeStatuses"/> field of <paramref name="options"/>, then | ||
| /// a new orchestration may be recreated automatically, depending on the configuration of the backend instance store. | ||
| /// If the existing orchestration is in a non-terminal state (Pending, Running, etc.), then the orchestration will first | ||
| /// be terminated before the new orchestration is created. | ||
sophiatev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /// A null <see cref="StartOrchestrationOptions.DedupeStatuses"/> field means the deduplication behavior will follow | ||
| /// whatever the default deduplication behavior of the backend instance store is. A non-null, empty field means that all | ||
| /// statuses are reusable. | ||
| /// </para><para> | ||
sophiatev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /// Orchestration instances started with this method will be created in the | ||
| /// <see cref="OrchestrationRuntimeStatus.Pending"/> state and will transition to the | ||
|
|
@@ -98,15 +103,18 @@ | |
| /// </param> | ||
| /// <param name="options">The options to start the new orchestration with.</param> | ||
| /// <param name="cancellation"> | ||
| /// The cancellation token. This only cancels enqueueing the new orchestration to the backend. Does not cancel the | ||
| /// orchestration once enqueued. | ||
| /// The cancellation token. This only cancels enqueueing the new orchestration to the backend, or waiting for the | ||
| /// termination of an existing non-terminal instance if its status is not in | ||
| /// <see cref="StartOrchestrationOptions.DedupeStatuses"/>. Does not cancel the orchestration once enqueued. | ||
| /// </param> | ||
| /// <returns> | ||
| /// A task that completes when the orchestration instance is successfully scheduled. The value of this task is | ||
| /// the instance ID of the scheduled orchestration instance. If a non-null instance ID was provided via | ||
| /// <paramref name="options" />, the same value will be returned by the completed task. | ||
| /// </returns> | ||
| /// <exception cref="ArgumentNullException">Thrown if <paramref name="orchestratorName"/> is empty.</exception> | ||
| /// <exception cref="OrchestrationAlreadyExistsException">If an orchestration with status in | ||
| /// <see cref="StartOrchestrationOptions.DedupeStatuses"/> with this instance ID already exists.</exception> | ||
| public abstract Task<string> ScheduleNewOrchestrationInstanceAsync( | ||
| TaskName orchestratorName, | ||
| object? input = null, | ||
|
|
@@ -529,7 +537,7 @@ | |
| throw new NotSupportedException( | ||
| $"{this.GetType()} does not support listing orchestration instance IDs filtered by completed time."); | ||
| } | ||
|
|
||
|
Check warning on line 540 in src/Client/Core/DurableTaskClient.cs
|
||
| // TODO: Create task hub | ||
|
|
||
| // TODO: Delete task hub | ||
|
|
@@ -539,3 +547,3 @@ | |
| /// </summary> | ||
| /// <returns>A <see cref="ValueTask"/> that completes when the disposal completes.</returns> | ||
| public abstract ValueTask DisposeAsync(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,14 +9,20 @@ | |
| /// Extension methods for <see cref="StartOrchestrationOptions"/> to provide type-safe deduplication status configuration. | ||
| /// </summary> | ||
| public static class StartOrchestrationOptionsExtensions | ||
| { | ||
| { | ||
| #pragma warning disable CS0618 // Type or member is obsolete - Cancelled is intentionally included for compatibility with the | ||
| // Durable Task Framework | ||
| public static readonly OrchestrationRuntimeStatus[] ValidDedupeStatuses = new[] | ||
|
Check warning on line 15 in src/Client/Core/StartOrchestrationOptionsExtensions.cs
|
||
| { | ||
| OrchestrationRuntimeStatus.Completed, | ||
| OrchestrationRuntimeStatus.Failed, | ||
| OrchestrationRuntimeStatus.Terminated, | ||
| OrchestrationRuntimeStatus.Terminated, | ||
| OrchestrationRuntimeStatus.Canceled, | ||
| }; | ||
| OrchestrationRuntimeStatus.Pending, | ||
| OrchestrationRuntimeStatus.Running, | ||
| OrchestrationRuntimeStatus.Suspended, | ||
| }; | ||
| #pragma warning restore CS0618 // Type or member is obsolete | ||
|
|
||
| /// <summary> | ||
| /// Creates a new <see cref="StartOrchestrationOptions"/> with the specified deduplication statuses. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| using System.Collections.Immutable; | ||
| using System.Diagnostics; | ||
| using System.Text; | ||
| using DurableTask.Core.Exceptions; | ||
| using DurableTask.Core.History; | ||
| using Google.Protobuf.WellKnownTypes; | ||
| using Microsoft.DurableTask.Client.Entities; | ||
|
|
@@ -124,9 +125,7 @@ public override async Task<string> ScheduleNewOrchestrationInstanceAsync( | |
| } | ||
|
|
||
| // Set orchestration ID reuse policy for deduplication support | ||
| // Note: This requires the protobuf to support OrchestrationIdReusePolicy field | ||
| // If the protobuf doesn't support it yet, this will need to be updated when the protobuf is updated | ||
| if (options?.DedupeStatuses != null && options.DedupeStatuses.Count > 0) | ||
| if (options?.DedupeStatuses != null) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the reason for removing the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is indeed a behavior change. My thinking is:
Previously, I think both situations would default to whatever the backend does |
||
| { | ||
| // Parse and validate all status strings to enum first | ||
| ImmutableHashSet<OrchestrationRuntimeStatus> dedupeStatuses = options.DedupeStatuses | ||
|
|
@@ -143,19 +142,21 @@ public override async Task<string> ScheduleNewOrchestrationInstanceAsync( | |
|
|
||
| // Convert dedupe statuses to protobuf statuses and create reuse policy | ||
| IEnumerable<P.OrchestrationStatus> dedupeStatusesProto = dedupeStatuses.Select(s => s.ToGrpcStatus()); | ||
| P.OrchestrationIdReusePolicy? policy = ProtoUtils.ConvertDedupeStatusesToReusePolicy(dedupeStatusesProto); | ||
|
|
||
| if (policy != null) | ||
| { | ||
| request.OrchestrationIdReusePolicy = policy; | ||
| } | ||
| request.OrchestrationIdReusePolicy = ProtoUtils.ConvertDedupeStatusesToReusePolicy(dedupeStatusesProto); | ||
| } | ||
|
|
||
| using Activity? newActivity = TraceHelper.StartActivityForNewOrchestration(request); | ||
|
|
||
| P.CreateInstanceResponse? result = await this.sidecarClient.StartInstanceAsync( | ||
| try | ||
| { | ||
| P.CreateInstanceResponse? result = await this.sidecarClient.StartInstanceAsync( | ||
| request, cancellationToken: cancellation); | ||
| return result.InstanceId; | ||
| return result.InstanceId; | ||
| } | ||
| catch (RpcException e) when (e.StatusCode == StatusCode.AlreadyExists) | ||
| { | ||
| throw new OrchestrationAlreadyExistsException(e.Status.Detail); | ||
| } | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.