Skip to content

Commit 958ec3a

Browse files
author
Sophia Tevosyan
committed
Merge branch 'main' into stevosyan/distributed-tracing-for-entities-isolated
2 parents f09df53 + 92ab676 commit 958ec3a

File tree

15 files changed

+255
-13
lines changed

15 files changed

+255
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Add user agent header to gRPC called in ([#417](https://github.com/microsoft/durabletask-dotnet/pull/417))
99
- Enrich User-Agent Header in gRPC Metadata to indicate Client or Worker as caller ([#421](https://github.com/microsoft/durabletask-dotnet/pull/421))
1010
- Add extension methods for registering entities by type ([#427](https://github.com/microsoft/durabletask-dotnet/pull/427))
11+
- Add TaskVersion and utilize it for version overrides when starting orchestrations ([#416](https://github.com/microsoft/durabletask-dotnet/pull/416))
1112

1213
## v1.10.0
1314

eng/ci/code-mirror.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ trigger:
44
# These are the branches we'll mirror to our internal ADO instance
55
# Keep this set limited as appropriate (don't mirror individual user branches).
66
- main
7+
- vabachu/release-testing
78

89
resources:
910
repositories:
@@ -16,4 +17,4 @@ variables:
1617
- template: ci/variables/cfs.yml@eng
1718

1819
extends:
19-
template: ci/code-mirror.yml@eng
20+
template: ci/code-mirror.yml@eng

eng/ci/official-build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ trigger:
1212
branches:
1313
include:
1414
- main
15+
- vabachu/release-testing
1516

1617
# CI only, does not trigger on PRs.
1718
pr: none
@@ -50,4 +51,4 @@ extends:
5051
- stage: BuildAndSign
5152
dependsOn: []
5253
jobs:
53-
- template: /eng/templates/build.yml@self
54+
- template: /eng/templates/build.yml@self

src/Abstractions/TaskName.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace Microsoft.DurableTask;
1616
/// <param name="name">The name of the task. Providing <c>null</c> will yield the default struct.</param>
1717
public TaskName(string name)
1818
{
19+
#pragma warning disable 0618
1920
if (name is null)
2021
{
2122
// Force the default struct when null is passed in.
@@ -27,6 +28,7 @@ public TaskName(string name)
2728
this.Name = name;
2829
this.Version = string.Empty; // expose setting Version only when we actually consume it.
2930
}
31+
#pragma warning restore 0618
3032
}
3133

3234
/// <summary>
@@ -44,6 +46,7 @@ public TaskName(string name)
4446
/// Task versions is currently locked to <see cref="string.Empty" /> as it is not yet integrated into task
4547
/// identification. This is being left here as we intend to support it soon.
4648
/// </remarks>
49+
[Obsolete("Refer to TaskVersion instead.")]
4750
public string Version { get; }
4851

4952
/// <summary>
@@ -122,6 +125,7 @@ public override int GetHashCode()
122125
/// <returns>The name and optional version of the current <see cref="TaskName"/> instance.</returns>
123126
public override string ToString()
124127
{
128+
#pragma warning disable 0618
125129
if (string.IsNullOrEmpty(this.Version))
126130
{
127131
return this.Name;
@@ -130,5 +134,6 @@ public override string ToString()
130134
{
131135
return this.Name + ":" + this.Version;
132136
}
137+
#pragma warning restore 0618
133138
}
134139
}

src/Abstractions/TaskOptions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ public SubOrchestrationOptions(TaskOptions options, string? instanceId = null)
9090
/// Gets the orchestration instance ID.
9191
/// </summary>
9292
public string? InstanceId { get; init; }
93+
94+
/// <summary>
95+
/// Gets the version to associate with the sub-orchestration instance.
96+
/// </summary>
97+
public TaskVersion Version { get; init; } = default!;
9398
}
9499

95100
/// <summary>
@@ -108,4 +113,9 @@ public record StartOrchestrationOptions(string? InstanceId = null, DateTimeOffse
108113
/// Gets the tags to associate with the orchestration instance.
109114
/// </summary>
110115
public IReadOnlyDictionary<string, string> Tags { get; init; } = ImmutableDictionary.Create<string, string>();
116+
117+
/// <summary>
118+
/// Gets the version to associate with the orchestration instance.
119+
/// </summary>
120+
public TaskVersion? Version { get; init; }
111121
}

src/Abstractions/TaskVersion.cs

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
namespace Microsoft.DurableTask;
5+
6+
/// <summary>
7+
/// The version of a durable task.
8+
/// </summary>
9+
public readonly struct TaskVersion : IEquatable<TaskVersion>
10+
{
11+
/// <summary>
12+
/// Initializes a new instance of the <see cref="TaskVersion"/> struct.
13+
/// </summary>
14+
/// <param name="version">The version of the task. Providing <c>null</c> will result in the default struct.</param>
15+
public TaskVersion(string version)
16+
{
17+
if (version == null)
18+
{
19+
this.Version = null!;
20+
}
21+
else
22+
{
23+
this.Version = version;
24+
}
25+
}
26+
27+
/// <summary>
28+
/// Gets the version of a task.
29+
/// </summary>
30+
public string Version { get; }
31+
32+
/// <summary>
33+
/// Implicitly converts a <see cref="TaskVersion"/> into a <see cref="string"/> of the <see cref="Version"/> property value.
34+
/// </summary>
35+
/// <param name="value">The <see cref="TaskVersion"/> to be converted into a <see cref="string"/>.</param>
36+
public static implicit operator string(TaskVersion value) => value.Version;
37+
38+
/// <summary>
39+
/// Implicitly converts a <see cref="string"/> into a <see cref="TaskVersion"/>.
40+
/// </summary>
41+
/// <param name="value">The <see cref="string"/> to convert into a <see cref="TaskVersion"/>.</param>
42+
public static implicit operator TaskVersion(string value) => new TaskVersion(value);
43+
44+
/// <summary>
45+
/// Compares two <see cref="TaskVersion"/> structs for equality.
46+
/// </summary>
47+
/// <param name="a">The first <see cref="TaskVersion"/> to compare.</param>
48+
/// <param name="b">The second <see cref="TaskVersion"/> to compare.</param>
49+
/// <returns><c>true</c> if the two <see cref="TaskVersion"/> objects are equal; otherwise <c>false</c>.</returns>
50+
public static bool operator ==(TaskVersion a, TaskVersion b)
51+
{
52+
return a.Equals(b);
53+
}
54+
55+
/// <summary>
56+
/// Compares two <see cref="TaskVersion"/> structs for inequality.
57+
/// </summary>
58+
/// <param name="a">The first <see cref="TaskVersion"/> to compare.</param>
59+
/// <param name="b">The second <see cref="TaskVersion"/> to compare.</param>
60+
/// <returns><c>false</c> if the two <see cref="TaskVersion"/> objects are equal; otherwise <c>true</c>.</returns>
61+
public static bool operator !=(TaskVersion a, TaskVersion b)
62+
{
63+
return !a.Equals(b);
64+
}
65+
66+
/// <summary>
67+
/// Gets a value indicating whether to <see cref="TaskVersion"/> objects
68+
/// are equal using value semantics.
69+
/// </summary>
70+
/// <param name="other">The other <see cref="TaskVersion"/> to compare to.</param>
71+
/// <returns><c>true</c> if the two <see cref="TaskVersion"/> are equal using value semantics; otherwise <c>false</c>.</returns>
72+
public bool Equals(TaskVersion other)
73+
{
74+
return string.Equals(this.Version, other.Version, StringComparison.OrdinalIgnoreCase);
75+
}
76+
77+
/// <summary>
78+
/// Gets a value indicating whether to <see cref="TaskVersion"/> objects
79+
/// are equal using value semantics.
80+
/// </summary>
81+
/// <param name="obj">The other object to compare to.</param>
82+
/// <returns><c>true</c> if the two objects are equal using value semantics; otherwise <c>false</c>.</returns>
83+
public override bool Equals(object? obj)
84+
{
85+
if (obj is not TaskVersion other)
86+
{
87+
return false;
88+
}
89+
90+
return this.Equals(other);
91+
}
92+
93+
/// <summary>
94+
/// Calculates a hash code value for the current <see cref="TaskVersion"/> instance.
95+
/// </summary>
96+
/// <returns>A 32-bit hash code value.</returns>
97+
public override int GetHashCode()
98+
{
99+
return StringComparer.OrdinalIgnoreCase.GetHashCode(this.Version);
100+
}
101+
}

src/Client/Grpc/GrpcDurableTaskClient.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,11 @@ public override async Task<string> ScheduleNewOrchestrationInstanceAsync(
7878
{
7979
Check.NotEntity(this.options.EnableEntitySupport, options?.InstanceId);
8080

81+
// We're explicitly OK with an empty version from the options as that had to be explicitly set. It should take precedence over the default.
8182
string version = string.Empty;
82-
if (!string.IsNullOrEmpty(orchestratorName.Version))
83+
if (options?.Version is { } v)
8384
{
84-
version = orchestratorName.Version;
85+
version = v;
8586
}
8687
else if (!string.IsNullOrEmpty(this.options.DefaultVersion))
8788
{

src/Client/OrchestrationServiceClientShim/ShimDurableTaskClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public override async Task<string> ScheduleNewOrchestrationInstanceAsync(
184184
Event = new ExecutionStartedEvent(-1, serializedInput)
185185
{
186186
Name = orchestratorName.Name,
187-
Version = orchestratorName.Version,
187+
Version = options?.Version ?? string.Empty,
188188
OrchestrationInstance = instance,
189189
ScheduledStartTime = options?.StartAt?.UtcDateTime,
190190
ParentTraceContext = Activity.Current is { } activity ? new Core.Tracing.DistributedTraceContext(activity.Id!, activity.TraceStateString) : null,

src/Worker/Core/DependencyInjection/DurableTaskWorkerBuilderExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public static IDurableTaskWorkerBuilder UseVersioning(this IDurableTaskWorkerBui
102102
options.Versioning = new VersioningOptions
103103
{
104104
Version = versionOptions.Version,
105+
DefaultVersion = versionOptions.DefaultVersion,
105106
MatchStrategy = versionOptions.MatchStrategy,
106107
FailureStrategy = versionOptions.FailureStrategy,
107108
};

src/Worker/Core/DurableTaskWorkerOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ public class VersioningOptions
203203
/// </summary>
204204
public string Version { get; set; } = string.Empty;
205205

206+
/// <summary>
207+
/// Gets or sets the default version that will be used for starting new orchestrations.
208+
/// </summary>
209+
public string DefaultVersion { get; set; } = string.Empty;
210+
206211
/// <summary>
207212
/// Gets or sets the versioning strategy for the Durable Task worker.
208213
/// </summary>

0 commit comments

Comments
 (0)