in src/orchestrations/TaskOrchestrationExecutor.ts [94:129]
public async execute(
context: OrchestrationContext,
history: HistoryEvent[],
schemaVersion: ReplaySchema,
fn: (context: OrchestrationContext) => IterableIterator<unknown>
): Promise<OrchestratorState> {
this.schemaVersion = schemaVersion;
this.context = context.df;
this.generator = fn(context) as Generator<TaskBase, any, any>;
// Execute the orchestration, using the history for replay
for (const historyEvent of history) {
this.processEvent(historyEvent);
if (this.isDoneExecuting()) {
break;
}
}
// Construct current orchestration state
const actions: IAction[][] = this.actions.length == 0 ? [[]] : [this.actions];
const orchestratorState = new OrchestratorState({
isDone: this.hasCompletedSuccessfully(),
actions: actions,
output: this.output,
error: this.exception?.message,
customStatus: this.context.customStatus,
schemaVersion: this.schemaVersion,
});
// Throw errors, if any
if (this.exception !== undefined) {
throw new OrchestrationFailureError(this.orchestratorReturned, orchestratorState);
}
return orchestratorState;
}