-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathStartOrchestrationOptionsExtensions.cs
More file actions
56 lines (51 loc) · 2.17 KB
/
StartOrchestrationOptionsExtensions.cs
File metadata and controls
56 lines (51 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System.Linq;
namespace Microsoft.DurableTask.Client;
/// <summary>
/// Extension methods for <see cref="StartOrchestrationOptions"/> to provide type-safe deduplication status configuration.
/// </summary>
public static class StartOrchestrationOptionsExtensions
{
/// <summary>
/// Gets the valid terminal orchestration statuses that can be used for deduplication and ID reuse policies.
/// </summary>
public static readonly OrchestrationRuntimeStatus[] ValidDedupeStatuses = new[]
{
OrchestrationRuntimeStatus.Completed,
OrchestrationRuntimeStatus.Failed,
OrchestrationRuntimeStatus.Terminated,
OrchestrationRuntimeStatus.Canceled,
};
/// <summary>
/// Creates a new <see cref="StartOrchestrationOptions"/> with the specified deduplication statuses.
/// </summary>
/// <param name="options">The base options to extend.</param>
/// <param name="dedupeStatuses">The orchestration runtime statuses that should be considered for deduplication.</param>
/// <returns>A new <see cref="StartOrchestrationOptions"/> instance with the deduplication statuses set.</returns>
public static StartOrchestrationOptions WithDedupeStatuses(
this StartOrchestrationOptions options,
params OrchestrationRuntimeStatus[] dedupeStatuses)
{
return options with
{
DedupeStatuses = dedupeStatuses.Select(s => s.ToString()).ToList(),
};
}
/// <summary>
/// Creates a new <see cref="StartOrchestrationOptions"/> with the specified orchestration ID reuse policy.
/// </summary>
/// <param name="options">The base options to extend.</param>
/// <param name="policy">The orchestration ID reuse policy.</param>
/// <returns>A new <see cref="StartOrchestrationOptions"/> instance with the ID reuse policy set.</returns>
public static StartOrchestrationOptions WithIdReusePolicy(
this StartOrchestrationOptions options,
OrchestrationIdReusePolicy policy)
{
Check.NotNull(policy);
return options with
{
IdReusePolicy = policy,
};
}
}