Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Client/Core/DurableTaskClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,13 @@
string instanceId,
bool restartWithNewInstanceId = false,
CancellationToken cancellation = default)
=> throw new NotSupportedException($"{this.GetType()} does not support orchestration restart.");
=> throw new NotSupportedException($"{this.GetType()} does not support orchestration restart.");

public virtual Task RewindInstanceAsync(

Check warning on line 443 in src/Client/Core/DurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

Check warning on line 443 in src/Client/Core/DurableTaskClient.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'DurableTaskClient.RewindInstanceAsync(string, string, CancellationToken)'
string instanceId,
string reason,
CancellationToken cancellation = default)
=> throw new NotSupportedException($"{this.GetType()} does not support orchestration rewind.");

// TODO: Create task hub

Expand Down
7 changes: 6 additions & 1 deletion src/Client/Core/OrchestrationRuntimeStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,10 @@ public enum OrchestrationRuntimeStatus
/// <summary>
/// The orchestration has been suspended.
/// </summary>
Suspended,
Suspended,

/// <summary>
/// The orchestration is rewinding.
/// </summary>
Rewinding,
}
35 changes: 35 additions & 0 deletions src/Client/Grpc/GrpcDurableTaskClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,41 @@ public override async Task<string> RestartAsync(
}
}

public override async Task RewindInstanceAsync(
string instanceId,
string reason,
CancellationToken cancellation = default)
{
Check.NotNullOrEmpty(instanceId);
Check.NotEntity(this.options.EnableEntitySupport, instanceId);

var request = new P.RewindInstanceRequest
{
InstanceId = instanceId,
Reason = reason,
};
try
{
await this.sidecarClient.RewindInstanceAsync(request, cancellationToken: cancellation);
}
catch (RpcException e) when (e.StatusCode == StatusCode.NotFound)
{
throw new ArgumentException($"An orchestration with the instanceId {instanceId} was not found.", e);
}
catch (RpcException e) when (e.StatusCode == StatusCode.FailedPrecondition)
{
throw new InvalidOperationException(
$"The orchestration with the instanceId {instanceId} cannot be rewound. " +
$"Only orchestrations in the \"Failed\" state can be rewound.",
e);
}
catch (RpcException e) when (e.StatusCode == StatusCode.Cancelled)
{
throw new OperationCanceledException(
$"The {nameof(this.RewindInstanceAsync)} operation was canceled.", e, cancellation);
}
}

static AsyncDisposable GetCallInvoker(GrpcDurableTaskClientOptions options, out CallInvoker callInvoker)
{
if (options.Channel is GrpcChannel c)
Expand Down
3 changes: 2 additions & 1 deletion src/Client/Grpc/ProtoUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
OrchestrationRuntimeStatus.Pending => P.OrchestrationStatus.Pending,
OrchestrationRuntimeStatus.Running => P.OrchestrationStatus.Running,
OrchestrationRuntimeStatus.Terminated => P.OrchestrationStatus.Terminated,
OrchestrationRuntimeStatus.Suspended => P.OrchestrationStatus.Suspended,
OrchestrationRuntimeStatus.Suspended => P.OrchestrationStatus.Suspended,
OrchestrationRuntimeStatus.Rewinding => P.OrchestrationStatus.Rewinding,

Check failure on line 30 in src/Client/Grpc/ProtoUtils.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

'OrchestrationStatus' does not contain a definition for 'Rewinding'

Check failure on line 30 in src/Client/Grpc/ProtoUtils.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

'OrchestrationStatus' does not contain a definition for 'Rewinding'

Check failure on line 30 in src/Client/Grpc/ProtoUtils.cs

View workflow job for this annotation

GitHub Actions / build

'OrchestrationStatus' does not contain a definition for 'Rewinding'

Check failure on line 30 in src/Client/Grpc/ProtoUtils.cs

View workflow job for this annotation

GitHub Actions / build

'OrchestrationStatus' does not contain a definition for 'Rewinding'
_ => throw new ArgumentOutOfRangeException(nameof(status), "Unexpected value"),
};
#pragma warning restore 0618 // Referencing Obsolete member.
Expand Down
3 changes: 3 additions & 0 deletions src/Shared/Grpc/ProtoUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@
Tags = proto.HistoryState.OrchestrationState.Tags,
});
break;
case P.HistoryEvent.EventTypeOneofCase.ExecutionRewound:

Check failure on line 222 in src/Shared/Grpc/ProtoUtils.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

'HistoryEvent.EventTypeOneofCase' does not contain a definition for 'ExecutionRewound'

Check failure on line 222 in src/Shared/Grpc/ProtoUtils.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

'HistoryEvent.EventTypeOneofCase' does not contain a definition for 'ExecutionRewound'

Check failure on line 222 in src/Shared/Grpc/ProtoUtils.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

'HistoryEvent.EventTypeOneofCase' does not contain a definition for 'ExecutionRewound'

Check failure on line 222 in src/Shared/Grpc/ProtoUtils.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

'HistoryEvent.EventTypeOneofCase' does not contain a definition for 'ExecutionRewound'

Check failure on line 222 in src/Shared/Grpc/ProtoUtils.cs

View workflow job for this annotation

GitHub Actions / build

'HistoryEvent.EventTypeOneofCase' does not contain a definition for 'ExecutionRewound'

Check failure on line 222 in src/Shared/Grpc/ProtoUtils.cs

View workflow job for this annotation

GitHub Actions / build

'HistoryEvent.EventTypeOneofCase' does not contain a definition for 'ExecutionRewound'

Check failure on line 222 in src/Shared/Grpc/ProtoUtils.cs

View workflow job for this annotation

GitHub Actions / build

'HistoryEvent.EventTypeOneofCase' does not contain a definition for 'ExecutionRewound'

Check failure on line 222 in src/Shared/Grpc/ProtoUtils.cs

View workflow job for this annotation

GitHub Actions / build

'HistoryEvent.EventTypeOneofCase' does not contain a definition for 'ExecutionRewound'
historyEvent = new ExecutionRewoundEvent(proto.EventId);

Check failure on line 223 in src/Shared/Grpc/ProtoUtils.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The type or namespace name 'ExecutionRewoundEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 223 in src/Shared/Grpc/ProtoUtils.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The type or namespace name 'ExecutionRewoundEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 223 in src/Shared/Grpc/ProtoUtils.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The type or namespace name 'ExecutionRewoundEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 223 in src/Shared/Grpc/ProtoUtils.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The type or namespace name 'ExecutionRewoundEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 223 in src/Shared/Grpc/ProtoUtils.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'ExecutionRewoundEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 223 in src/Shared/Grpc/ProtoUtils.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'ExecutionRewoundEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 223 in src/Shared/Grpc/ProtoUtils.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'ExecutionRewoundEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 223 in src/Shared/Grpc/ProtoUtils.cs

View workflow job for this annotation

GitHub Actions / build

The type or namespace name 'ExecutionRewoundEvent' could not be found (are you missing a using directive or an assembly reference?)
break;
default:
throw new NotSupportedException($"Deserialization of {proto.EventTypeCase} is not supported.");
}
Expand Down
Loading