Skip to content

Commit

Permalink
Add planNext method to PubOrchestrator
Browse files Browse the repository at this point in the history
  • Loading branch information
WMXPY committed Nov 6, 2023
1 parent 25d444e commit 62bb031
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/orchestrator/orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@

import { PUB_ACTION_TYPE, PubAction } from "../action/definition/action";
import { initializeCreateTaskManager } from "../orchestration/initialize/create-tasks";
import { PUB_PLAN_TYPE, PubPlan } from "../plan/definition/plan";
import { applyActionOnTaskManager } from "../task/apply/apply";
import { PubTaskManager } from "../task/task-manager";
import { PubCachedWorkflowConfiguration } from "../workflow/cache/configuration";
import { PubWorkflowConfiguration } from "../workflow/definition/configuration";
import { planForNext } from "./plan/plan-next";

export class PubOrchestrator {

Expand Down Expand Up @@ -40,4 +42,9 @@ export class PubOrchestrator {
const applyResult: boolean = applyActionOnTaskManager(action, this._taskManager);
return applyResult;
}

public planNext(): Array<PubPlan<PUB_PLAN_TYPE>> {

return planForNext(this._configuration, this._taskManager);
}
}
18 changes: 18 additions & 0 deletions src/orchestrator/plan/plan-next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
* @description Plan Next
*/

import { createPubPlan } from "../../plan/create";
import { PUB_PLAN_TYPE, PubPlan } from "../../plan/definition/plan";
import { PUB_PROCEDURE_TYPE, PubProcedureConfiguration } from "../../procedure/definition/configuration";
import { PUB_TASK_TYPE } from "../../task/definition/task";
import { PubTaskBase } from "../../task/task-base";
import { PubTaskManager } from "../../task/task-manager";
import { PubCachedWorkflowConfiguration } from "../../workflow/cache/configuration";
Expand All @@ -20,5 +23,20 @@ export const planForNext = (
return [];
}

const nextPlans: Array<PubPlan<PUB_PLAN_TYPE>> = [];
for (const nextExecutableTask of nextExecutableTasks) {

if (nextExecutableTask.taskType === PUB_TASK_TYPE.DRIVER) {

nextPlans.push(createPubPlan(
PUB_PLAN_TYPE.EXECUTE_DRIVER,
{
procedure: nextExecutableTask.procedure as PubProcedureConfiguration<PUB_PROCEDURE_TYPE.DRIVER>,
input: nextExecutableTask.getExecuteInput().getOrThrow(),
},
));
}
}

return [];
};

0 comments on commit 62bb031

Please sign in to comment.