Skip to content

Commit 8576bc5

Browse files
sophiatevSophia Tevosyan
andauthored
Adding Rewind to the SDK Layer (#1250)
* committing what i have for now * finishing up the initial implementation * everything is working * removed unused usings * fixed distributed tracing * added some comments * added changes to avoid altering the original runtime state * changed a comment * addressing PR comments * fixing the build errors * fixing another build error * updating a comment * updating package versions * updated patch version not minor version --------- Co-authored-by: Sophia Tevosyan <stevosyan@microsoft.com>
1 parent 852837c commit 8576bc5

12 files changed

Lines changed: 352 additions & 14 deletions

src/DurableTask.ApplicationInsights/DurableTask.ApplicationInsights.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<!-- Version Info -->
1212
<PropertyGroup>
1313
<MajorVersion>0</MajorVersion>
14-
<MinorVersion>7</MinorVersion>
15-
<PatchVersion>1</PatchVersion>
14+
<MinorVersion>8</MinorVersion>
15+
<PatchVersion>0</PatchVersion>
1616
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
1717
<FileVersion>$(VersionPrefix).0</FileVersion>
1818
<!-- FileVersionRevision is expected to be set by the CI. This is useful for distinguishing between multiple builds of the same version. -->

src/DurableTask.AzureStorage/DurableTask.AzureStorage.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
<!-- Version Info -->
2222
<PropertyGroup>
2323
<MajorVersion>2</MajorVersion>
24-
<MinorVersion>6</MinorVersion>
25-
<PatchVersion>1</PatchVersion>
24+
<MinorVersion>7</MinorVersion>
25+
<PatchVersion>0</PatchVersion>
2626
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
2727
<FileVersion>$(VersionPrefix).0</FileVersion>
2828
<!-- FileVersionRevision is expected to be set by the CI. This is useful for distinguishing between multiple builds of the same version. -->

src/DurableTask.Core/Command/OrchestratorActionType.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,10 @@ public enum OrchestratorActionType
4242
/// The orchestrator completed.
4343
/// </summary>
4444
OrchestrationComplete,
45+
46+
/// <summary>
47+
/// The orchestration was rewound.
48+
/// </summary>
49+
RewindOrchestration,
4550
}
4651
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// ----------------------------------------------------------------------------------
2+
// Copyright Microsoft Corporation
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
// ----------------------------------------------------------------------------------
13+
#nullable enable
14+
namespace DurableTask.Core.Command
15+
{
16+
17+
/// <summary>
18+
/// Orchestrator action for rewinding orchestrations.
19+
/// </summary>
20+
public class RewindOrchestrationAction : OrchestratorAction
21+
{
22+
/// <inheritdoc/>
23+
public override OrchestratorActionType OrchestratorActionType => OrchestratorActionType.RewindOrchestration;
24+
}
25+
}

src/DurableTask.Core/DurableTask.Core.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
<!-- Version Info -->
1818
<PropertyGroup>
1919
<MajorVersion>3</MajorVersion>
20-
<MinorVersion>5</MinorVersion>
21-
<PatchVersion>1</PatchVersion>
20+
<MinorVersion>6</MinorVersion>
21+
<PatchVersion>0</PatchVersion>
2222
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
2323
<FileVersion>$(VersionPrefix).0</FileVersion>
2424
<!-- FileVersionRevision is expected to be set by the CI. This is useful for distinguishing between multiple builds of the same version. -->

src/DurableTask.Core/History/EventType.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,10 @@ public enum EventType
125125
/// Orchestration was resumed event
126126
/// </summary>
127127
ExecutionResumed,
128+
129+
/// <summary>
130+
/// Orchestration was rewound event.
131+
/// </summary>
132+
ExecutionRewound,
128133
}
129134
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// ----------------------------------------------------------------------------------
2+
// Copyright Microsoft Corporation
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
// ----------------------------------------------------------------------------------
13+
#nullable enable
14+
namespace DurableTask.Core.History
15+
{
16+
using DurableTask.Core.Tracing;
17+
using System.Runtime.Serialization;
18+
19+
/// <summary>
20+
/// Generic History event
21+
/// </summary>
22+
[DataContract]
23+
public class ExecutionRewoundEvent : HistoryEvent, ISupportsDurableTraceContext
24+
{
25+
/// <summary>
26+
/// Creates a new ExecutionRewoundEvent with the supplied event id and empty reason.
27+
/// </summary>
28+
/// <param name="eventId">The integer event id</param>
29+
public ExecutionRewoundEvent(int eventId) : base(eventId) { }
30+
31+
/// <summary>
32+
/// Creates a new ExecutionRewoundEvent with the supplied event id and reason.
33+
/// </summary>
34+
/// <param name="eventId">The integer event id</param>
35+
/// <param name="reason">The reason for the rewind event</param>
36+
public ExecutionRewoundEvent(int eventId, string? reason)
37+
: base(eventId)
38+
{
39+
this.Reason = reason;
40+
}
41+
42+
/// <summary>
43+
/// Gets the event type
44+
/// </summary>
45+
public override EventType EventType => EventType.ExecutionRewound;
46+
47+
/// <summary>
48+
/// Gets or sets the reason for the rewind event.
49+
/// </summary>
50+
[DataMember]
51+
public string? Reason { get; set; }
52+
53+
/// <summary>
54+
/// Gets or sets the parent execution id of the rewound suborchestration.
55+
/// </summary>
56+
[DataMember]
57+
public string? ParentExecutionId { get; set; }
58+
59+
/// <summary>
60+
/// Gets or sets the instance ID of the rewound orchestration.
61+
/// </summary>
62+
[DataMember]
63+
public string? InstanceId { get; set; }
64+
65+
/// <summary>
66+
/// Gets or sets the parent trace context of the rewound suborchestration.
67+
/// </summary>
68+
[DataMember]
69+
public DistributedTraceContext? ParentTraceContext { get; set; }
70+
}
71+
}

src/DurableTask.Core/History/ExecutionStartedEvent.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,31 @@ internal ExecutionStartedEvent()
4848
{
4949
}
5050

51+
/// <summary>
52+
/// Creates a new ExecutionStartedEvent with the same fields as <paramref name="other"/>.
53+
/// A deep copy is performed on all non-base class fields.
54+
/// </summary>
55+
internal ExecutionStartedEvent(ExecutionStartedEvent other)
56+
{
57+
// Copy base class fields
58+
EventId = other.EventId;
59+
Timestamp = other.Timestamp;
60+
ExtensionData = other.ExtensionData;
61+
IsPlayed = other.IsPlayed;
62+
63+
// Deep copy all other fields
64+
OrchestrationInstance = other.OrchestrationInstance?.Clone();
65+
ParentInstance = other.ParentInstance?.Clone();
66+
ParentTraceContext = other.ParentTraceContext?.Clone();
67+
Input = other.Input;
68+
Name = other.Name;
69+
Version = other.Version;
70+
Tags = other.Tags != null ? new Dictionary<string, string>(other.Tags) : null;
71+
Correlation = other.Correlation;
72+
ScheduledStartTime = other.ScheduledStartTime;
73+
Generation = other.Generation;
74+
}
75+
5176
/// <summary>
5277
/// Gets the event type
5378
/// </summary>

src/DurableTask.Core/History/SubOrchestrationInstanceCreatedEvent.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,25 @@ public SubOrchestrationInstanceCreatedEvent(int eventId)
3030
{
3131
}
3232

33+
/// <summary>
34+
/// Creates a new ExecutionStartedEvent with the same fields as <paramref name="other"/>.
35+
/// </summary>
36+
internal SubOrchestrationInstanceCreatedEvent(SubOrchestrationInstanceCreatedEvent other)
37+
{
38+
// Copy base class fields
39+
EventId = other.EventId;
40+
Timestamp = other.Timestamp;
41+
ExtensionData = other.ExtensionData;
42+
IsPlayed = other.IsPlayed;
43+
44+
// Copy all other fields
45+
Name = other.Name;
46+
Version = other.Version;
47+
InstanceId = other.InstanceId;
48+
Input = other.Input;
49+
ClientSpanId = other.ClientSpanId;
50+
}
51+
3352
/// <summary>
3453
/// Gets the event type
3554
/// </summary>

src/DurableTask.Core/OrchestrationStatus.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ public enum OrchestrationStatus
5656
/// <summary>
5757
/// Orchestration state of suspended
5858
/// </summary>
59-
Suspended,
59+
Suspended
6060
}
6161
}

0 commit comments

Comments
 (0)