Package com.tnsai.coordination.workflow
Class ExecutionPlan
java.lang.Object
com.tnsai.coordination.workflow.ExecutionPlan
An execution plan with lifecycle control (pause, resume, cancel).
Wraps a list of workflow steps and executes them sequentially
with support for interrupting and resuming execution.
Example usage:
ExecutionPlan plan = ExecutionPlan.builder()
.id("plan-1")
.step("fetch", fetchAgent)
.step("analyze", analyzeAgent)
.step("report", reportAgent)
.build();
CompletableFuture<WorkflowResult> future = plan.start(new WorkflowContext("wf-1"));
plan.pause(); // pauses before next step
plan.resume(); // continues execution
plan.cancel(); // cancels remaining steps
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic enumExecution plan states. -
Method Summary
Modifier and TypeMethodDescriptionstatic ExecutionPlan.Builderbuilder()voidcancel()Cancels the execution.Returns results of completed steps so far.intReturns the index of the current/next step to execute.id()Returns the plan identifier.voidpause()Pauses execution before the next step begins.voidresume()Resumes a paused execution.start(WorkflowContext context) Starts executing the plan asynchronously.state()Returns the current execution state.intReturns the total number of steps.
-
Method Details
-
id
Returns the plan identifier. -
state
Returns the current execution state. -
completedSteps
Returns results of completed steps so far. -
totalSteps
public int totalSteps()Returns the total number of steps. -
currentStepIndex
public int currentStepIndex()Returns the index of the current/next step to execute. -
start
Starts executing the plan asynchronously. Returns a future that completes when the plan finishes, is cancelled, or fails. -
pause
public void pause()Pauses execution before the next step begins. No-op if already paused or not running. -
resume
public void resume()Resumes a paused execution. No-op if not paused. -
cancel
public void cancel()Cancels the execution. Completed steps remain; remaining steps are skipped. -
builder
-