<?php

declare(strict_types=1);

namespace Drupal\flowdrop_interrupt\Message;

use Drupal\flowdrop_interrupt\Enum\InterruptType;

/**
 * Message descriptor for a Timer interrupt.
 *
 * Thrown (wrapped in an InterruptRequiredException) by Delay/Schedule
 * nodes. Carries the absolute fire-at timestamp; the message handler
 * stamps it onto the entity's `scheduled_at` field, where the cron-driven
 * ScheduledInterruptSweeper picks it up and resolves the interrupt once
 * due — resuming the pipeline through the standard resolution path.
 *
 * Timer interrupts carry no expiry: the sweep is their lifecycle.
 *
 * @api
 */
final class TimerInterruptMessage extends AbstractInterruptMessage {

  /**
   * Constructs a new TimerInterruptMessage.
   *
   * @param string $message
   *   Human-readable description (e.g. "Waiting until 2026-06-10T09:00").
   * @param int $fireAt
   *   Absolute unix timestamp at which the timer becomes due.
   * @param array<string, mixed> $context
   *   Opaque payload — never used as a lookup key by the framework.
   */
  public function __construct(
    string $message,
    public readonly int $fireAt,
    array $context = [],
  ) {
    parent::__construct(InterruptType::Timer, $message, $context);
  }

}
