46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Provisioning;
|
|
|
|
/**
|
|
* The outcome a step returns to the runner: advance to the next step, retry
|
|
* this step after a delay, or fail the run.
|
|
*/
|
|
final class StepResult
|
|
{
|
|
public const ADVANCE = 'advance';
|
|
public const RETRY = 'retry';
|
|
public const POLL = 'poll';
|
|
public const FAIL = 'fail';
|
|
|
|
private function __construct(
|
|
public readonly string $type,
|
|
public readonly int $afterSeconds = 0,
|
|
public readonly string $reason = '',
|
|
) {}
|
|
|
|
public static function advance(): self
|
|
{
|
|
return new self(self::ADVANCE);
|
|
}
|
|
|
|
public static function retry(int $afterSeconds, string $reason): self
|
|
{
|
|
return new self(self::RETRY, $afterSeconds, $reason);
|
|
}
|
|
|
|
/**
|
|
* Wait and re-run WITHOUT consuming the retry budget — for polling long
|
|
* operations (e.g. a reboot). The step enforces its own deadline via fail().
|
|
*/
|
|
public static function poll(int $afterSeconds, string $reason): self
|
|
{
|
|
return new self(self::POLL, $afterSeconds, $reason);
|
|
}
|
|
|
|
public static function fail(string $reason): self
|
|
{
|
|
return new self(self::FAIL, 0, $reason);
|
|
}
|
|
}
|