Task execution contracts and runtime adapters for Switon Framework.
composer require switon/executorRequirements: PHP 8.3+
use Switon\Core\Attribute\Autowired;
use Switon\Core\Contract\RunnerInterface;
use Switon\Executor\ExecutorInterface;
final class ReportRunner implements RunnerInterface
{
public function run(mixed $payload): array
{
return ['id' => $payload['id'] ?? null];
}
}
final class JobService
{
#[Autowired] protected ExecutorInterface $executor;
public function runOnce(): void
{
$futures = $this->executor->invokeAll([[ReportRunner::class, ['id' => 1]]]);
// inspect $futures[0]->isSuccessful(), result(), error()
}
}Docs: https://docs.switon.dev/latest/executor
MIT.