in src/DurableSDK/OrchestrationInvoker.cs [49:95]
public Hashtable InvokeInternalDurableSDK(
OrchestrationBindingInfo orchestrationBindingInfo,
IPowerShellServices powerShellServices)
{
var outputBuffer = new PSDataCollection<object>();
var context = orchestrationBindingInfo.Context;
// context.History should never be null when initializing CurrentUtcDateTime
var orchestrationStart = context.History.First(
e => e.EventType == HistoryEventType.OrchestratorStarted);
context.CurrentUtcDateTime = orchestrationStart.Timestamp.ToUniversalTime();
// Marks the first OrchestratorStarted event as processed
orchestrationStart.IsProcessed = true;
// Finish initializing the Function invocation
powerShellServices.AddParameter(orchestrationBindingInfo.ParameterName, context);
powerShellServices.TracePipelineObject();
var asyncResult = powerShellServices.BeginInvoke(outputBuffer);
var (shouldStop, actions) =
orchestrationBindingInfo.Context.OrchestrationActionCollector.WaitForActions(asyncResult.AsyncWaitHandle);
if (shouldStop)
{
// The orchestration function should be stopped and restarted
powerShellServices.StopInvoke();
return CreateOrchestrationResult(isDone: false, actions, output: null, context.CustomStatus);
}
else
{
try
{
// The orchestration function completed
powerShellServices.EndInvoke(asyncResult);
var result = CreateReturnValueFromFunctionOutput(outputBuffer);
return CreateOrchestrationResult(isDone: true, actions, output: result, context.CustomStatus);
}
catch (Exception e)
{
// The orchestrator code has thrown an unhandled exception:
// this should be treated as an entire orchestration failure
throw new OrchestrationFailureException(actions, context.CustomStatus, e);
}
}
}