public function processNextJob(
        $workQueue,
        callable $callback,
        int $timeout = WorkServerAdapter::DEFAULT_TIMEOUT
    ): void {
        $qe = $this->server->getNextQueueEntry($workQueue, $timeout);
        if (!$qe) {
            $this->onNoJobAvailable((array)$workQueue);
            return;
        }

        $job = $qe->getJob();

        if ($job->jobIsExpired()) {
            $this->handleExpiredJob($qe);
            return;
        }

        $this->log(LogLevel::INFO, "got job", $qe);
        $this->onJobAvailable($qe);

        $ret = null;
        try {
            $ret = $callback($job);
        } catch (\Throwable $e) {
            // The job failed.
            $this->handleFailedJob($qe, $e);

            if ($this->options[self::WP_RETHROW_EXCEPTIONS]) {
                // pass exception to caller
                throw $e;
            } else {
                // drop it
                return;
            }
        }

        switch ($ret ?? JobResult::DEFAULT) {
            case JobResult::SUCCESS:
                // The job succeeded!
                $this->handleFinishedJob($qe);
                break;
            case JobResult::FAILED:
                // The job failed.
                $this->handleFailedJob($qe);
                break;
            default:
                // We'll assume the job went well.
                $this->handleFinishedJob($qe);
                throw new \UnexpectedValueException('unexpected job handler return value, should be JobResult::... or null or void');
        }
    }