Class ExecutionPlan

java.lang.Object
com.tnsai.coordination.workflow.ExecutionPlan

public final class ExecutionPlan extends Object
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
 
  • Method Details

    • id

      public String id()
      Returns the plan identifier.
    • state

      public ExecutionPlan.State state()
      Returns the current execution state.
    • completedSteps

      public Map<String,WorkflowContext.StepResult> 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

      public static ExecutionPlan.Builder builder()