-
Notifications
You must be signed in to change notification settings - Fork 31
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
Implement support for suspend/resume #195
Changes from all commits
48a8609
095a8d1
a94977e
b71fb54
fc420b8
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 |
---|---|---|
|
@@ -205,6 +205,7 @@ public override Task DeleteAsync(bool deleteInstanceStore) | |
currentStatus = SqlUtils.GetRuntimeStatus(reader); | ||
isRunning = | ||
currentStatus == OrchestrationStatus.Running || | ||
currentStatus == OrchestrationStatus.Suspended || | ||
currentStatus == OrchestrationStatus.Pending; | ||
} | ||
else | ||
|
@@ -570,19 +571,7 @@ public override async Task<OrchestrationState> WaitForOrchestrationAsync( | |
return state; | ||
} | ||
|
||
try | ||
{ | ||
await Task.Delay(TimeSpan.FromSeconds(1), combinedCts.Token); | ||
} | ||
catch (TaskCanceledException) | ||
{ | ||
if (timeoutCts.Token.IsCancellationRequested) | ||
{ | ||
throw new TimeoutException($"A caller-specified timeout of {timeout} has expired, but instance '{instanceId}' is still in an {state?.OrchestrationStatus.ToString() ?? "unknown"} state."); | ||
} | ||
|
||
throw; | ||
} | ||
await Task.Delay(TimeSpan.FromSeconds(1), combinedCts.Token); | ||
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. The above code was deleted to ensure that we only throw |
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,9 +71,13 @@ public async Task<OrchestrationState> WaitForCompletion( | |
OrchestrationStatus expectedStatus = OrchestrationStatus.Completed, | ||
object expectedOutput = null, | ||
string expectedOutputRegex = null, | ||
bool continuedAsNew = false) | ||
bool continuedAsNew = false, | ||
bool doNotAdjustTimeout = false) | ||
{ | ||
AdjustTimeout(ref timeout); | ||
if (!doNotAdjustTimeout) | ||
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. Needed to add this, otherwise we can't write test code that waits for timeouts (like I do in my new test) when a debugger is attached. |
||
{ | ||
AdjustTimeout(ref timeout); | ||
} | ||
|
||
OrchestrationState state = await this.client.WaitForOrchestrationAsync(this.GetInstanceForAnyExecution(), timeout); | ||
Assert.NotNull(state); | ||
|
@@ -158,6 +162,17 @@ internal async Task RestartAsync(TInput newInput, OrchestrationStatus[] dedupeSt | |
this.instance.ExecutionId = newInstance.ExecutionId; | ||
} | ||
|
||
|
||
internal Task SuspendAsync(string reason = null) | ||
{ | ||
return this.client.SuspendInstanceAsync(this.instance, reason); | ||
} | ||
|
||
internal Task ResumeAsync(string reason = null) | ||
{ | ||
return this.client.ResumeInstanceAsync(this.instance, reason); | ||
} | ||
|
||
static void AdjustTimeout(ref TimeSpan timeout) | ||
{ | ||
timeout = timeout.AdjustForDebugging(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added long before we actually implemented suspend/resume in DurableTask.Core, and was based on the assumption that we wouldn't even load suspended orchestrations. In the final design, however, we decided that we needed to continue loading suspended orchestrations, so this line needed to be removed.