<?php

declare(strict_types=1);

namespace Drupal\flowdrop_runtime\Service\Orchestrator;

use Drupal\flowdrop_orchestration\DTO\Orchestrator\OrchestrationResponse;
use Drupal\flowdrop_pipeline\Entity\FlowDropPipelineInterface;

/**
 * Interface for orchestrators that can execute pipeline entities.
 *
 * This interface defines the contract for resuming or executing an existing
 * pipeline entity. It is used by event subscribers that need to resume
 * pipeline execution after an interrupt is resolved.
 *
 * @internal
 *   This class is not part of the public API and may change without notice.
 */
interface PipelineExecutorInterface {

  /**
   * Executes (or resumes) a pipeline entity.
   *
   * @param \Drupal\flowdrop_pipeline\Entity\FlowDropPipelineInterface $pipeline
   *   The pipeline to execute.
   * @param int|null $maxIterations
   *   Maximum number of iterations before pausing (default: 100).
   *   NULL means no limit.
   * @param float|null $maxExecutionTime
   *   Maximum execution time in seconds before pausing
   *   (default: NULL = no limit).
   *
   * @return \Drupal\flowdrop_orchestration\DTO\Orchestrator\OrchestrationResponse
   *   The orchestration response.
   */
  public function executePipeline(
    FlowDropPipelineInterface $pipeline,
    ?int $maxIterations = 100,
    ?float $maxExecutionTime = NULL,
  ): OrchestrationResponse;

}
