Created
November 28, 2017 05:11
-
-
Save gled4er/16970c68e0eb650cf363db6efe8a5741 to your computer and use it in GitHub Desktop.
Sync Response Orchestration Client
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
[FunctionName("SyncResponseClient")] | |
public static async Task<HttpResponseMessage> Run( | |
[HttpTrigger(AuthorizationLevel.Function, methods: "post", Route = "orchestrator/{functionName}")] HttpRequestMessage req, | |
[OrchestrationClient] DurableOrchestrationClient starter, | |
string functionName, | |
TraceWriter log) | |
{ | |
// Function input comes from the request content. | |
dynamic eventData = await req.Content.ReadAsAsync<object>(); | |
string instanceId = await starter.StartNewAsync(functionName, eventData); | |
log.Info($"Started orchestration with ID = '{instanceId}'."); | |
var responseMessage = starter.CreateCheckStatusResponse(req, instanceId); | |
var clientResponse = JsonConvert.DeserializeObject<OrchestrationClientResponse>(await responseMessage.Content.ReadAsStringAsync()); | |
var executionDetails = Helper.GetExecutionDetails(); | |
var durableFunctionSyncResponseService = new DurableFunctionSyncResponseService(); | |
var result = await durableFunctionSyncResponseService.ProvideOutput(clientResponse, executionDetails, log); | |
return result == null | |
? req.CreateResponse(HttpStatusCode.OK, $"The operation is taking more than expected. Keep following the progress here {clientResponse.StatusQueryGetUri}") : | |
req.CreateResponse(HttpStatusCode.OK, result); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment