-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
425 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
test/e2e/Apps/BasicDotNetIsolated/SuspendResumeOrchestration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using System.Net; | ||
using Grpc.Core; | ||
using Microsoft.Azure.Functions.Worker; | ||
using Microsoft.Azure.Functions.Worker.Http; | ||
using Microsoft.DurableTask.Client; | ||
|
||
namespace Microsoft.Azure.Durable.Tests.E2E; | ||
|
||
public static class SuspendResumeOrchestration | ||
{ | ||
[Function("SuspendInstance")] | ||
public static async Task<HttpResponseData> Suspend( | ||
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req, | ||
[DurableClient] DurableTaskClient client, | ||
string instanceId) | ||
{ | ||
string suspendReason = "Suspending the instance for test."; | ||
try | ||
{ | ||
await client.SuspendInstanceAsync(instanceId, suspendReason); | ||
return req.CreateResponse(HttpStatusCode.OK); | ||
} | ||
catch (RpcException ex) | ||
{ | ||
var response = req.CreateResponse(HttpStatusCode.BadRequest); | ||
response.Headers.Add("Content-Type", "text/plain"); | ||
await response.WriteStringAsync(ex.Message); | ||
return response; | ||
} | ||
} | ||
|
||
[Function("ResumeInstance")] | ||
public static async Task<HttpResponseData> Resume( | ||
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req, | ||
[DurableClient] DurableTaskClient client, | ||
string instanceId) | ||
{ | ||
string resumeReason = "Resuming the instance for test."; | ||
try | ||
{ | ||
await client.ResumeInstanceAsync(instanceId, resumeReason); | ||
return req.CreateResponse(HttpStatusCode.OK); | ||
} | ||
catch (RpcException ex) | ||
{ | ||
var response = req.CreateResponse(HttpStatusCode.BadRequest); | ||
response.Headers.Add("Content-Type", "text/plain"); | ||
await response.WriteStringAsync(ex.Message); | ||
return response; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.