*/ private array $jobs = []; public int $done = 0; public function push(Job $job): void { $this->jobs[] = $job; } public function process(string $snapshot, int $stopAt): int { $total = 0; foreach ($this->jobs as $i => $job) { $total += count($job->payload); $this->done++; if ($i === $stopAt) { cryo_freeze($snapshot, ['mode' => 'continue', 'compress' => 'zlib']); } } return $total; } } function runWorker(string $snapshot): int { $queue = new JobQueue(); foreach (['mail', 'resize', 'invoice', 'mail', 'export'] as $n => $kind) { $queue->push(new Job($n + 1, $kind, array_fill(0, $n + 2, "$kind data"))); } $started = 'batch-42'; return $queue->process($snapshot, 2); } $config = ['retries' => 3, 'queue' => 'orders']; echo 'processed ', runWorker(__DIR__ . '/worker.cryf'), " items\n";