Prepare the payload for storage on the queue by adding tags, etc.

@param  mixed  $job
@return $this
516721
public function prepare($job)
    {
        return $this->set([
            'type' => $this->determineType($job),
            'tags' => $this->determineTags($job),
            'pushedAt' => str_replace(',', '.', microtime(true)),
        ]);
    }
1157496
private function runJob($job)
    {
        try {
            $this->logger->notice("Job #{$this->currentJobId} [{$job->getName()}] started.");
            $status = $this->broker->getStatus($job->getId());
            $status['status'] = Job::STATUS_RUNNING;
            $status['started'] = date(DATE_RFC3339_EXTENDED);
            $this->broker->setStatus($job->getId(), $status);
            $job->setup();
            $response = $job->go();
            $job->tearDown();
            $status['status'] = Job::STATUS_FINISHED;
            $status['finished'] = date(DATE_RFC3339_EXTENDED);
            $status['response'] = $response;
            $this->broker->setStatus($job->getId(), $status);
            $this->logger->notice("Job #{$this->currentJobId} [{$job->getName()}] finished.");
        } catch (\Exception $e) {
            $status['status'] = Job::STATUS_FAILED;
            $status['failed'] = date(DATE_RFC3339_EXTENDED);
            $this->broker->setStatus($job->getId(), $status);
            $this->logException($e, "Job #{$this->currentJobId}  [{$job->getName()}] Exception");
            $this->logger->alert("Job #{$this->currentJobId}  [{$job->getName()}] died.");
        }
    }
743400
public function setJob(JobInterface $job)
    {
        $this->job = $job;
        
        $this->getRefs()->setJob($job);
        
        return $this;
    }
714790
protected function markJobAsReserved($job)
    {
        $this->database->createCommand()->update(
            $this->table, [
            'reserved_at' => $job->touch(),
            'attempts' => $job->increment(),
            ], [
            'id' => $job->id
            ]
        )->execute();

        return $job;
    }
453693
public function job($job, $queue = null)
    {
        return $this->call(
            function () use ($job, $queue) {
                $job = is_string($job) ? resolve($job) : $job;

                if ($job instanceof ShouldQueue) {
                    dispatch($job)->onQueue($queue);
                } else {
                    dispatch_now($job);
                }
            }
        )->name(is_string($job) ? $job : get_class($job));
    }
844424
protected function createPayload($job, $data = '', $queue = null)
    {
        if (is_object($job)) {
            $payload = json_encode([
                'job' => 'Globalis\PuppetSkilled\Queue\CallQueuedHandler@call',
                'data' => [
                    'commandName' => get_class($job),
                    'command' => serialize(clone $job),
                ],
            ]);
        } else {
            $payload = json_encode($this->createPlainPayload($job, $data));
        }

        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new InvalidArgumentException('Unable to create payload: '.json_last_error_msg());
        }

        return $payload;
    }
1242705
function uploadJob(Job $job): void {
    if (!$job->getRepoToken() && !$job->getServiceName())
      throw new \InvalidArgumentException('The job does not meet the requirements.');

    $uri = UriResolver::resolve($this->getEndPoint(), new Uri('jobs'));
    $body = new MultipartStream([[
      'contents' => json_encode($job, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE),
      'filename' => 'coveralls.json',
      'name' => 'json_file'
    ]]);

    $headers = [
      'content-length' => $body->getSize(),
      'content-type' => "multipart/form-data; boundary={$body->getBoundary()}"
    ];

    try {
      $request = new Request('POST', $uri, $headers, $body);
      $this->emit(new RequestEvent($request));

      $response = (new HTTPClient())->send($request);
      $this->emit(new ResponseEvent($request, $response));
    }

    catch (\Throwable $e) {
      throw new ClientException('An error occurred while uploading the report.', $uri, $e);
    }
  }
306809
public function serialize(Job $job)
    {
        $attributes = $job->getAttributes();
        $attributes['className'] = get_class($job);
        $attributes['type'] = $job->getType();
        return $attributes;
    }
1344819
private function pushSchedule($job)
    {
        $runTime = $job->getRunTime($this->currTime);

        if (array_key_exists($runTime, $this->schedule)) {
            $this->schedule = [$runTime => $job];
        } else {
            $this->schedule[$runTime][] = $job;
        }
    }
268763
protected function createPayloadArray($job, $queue, $data = '')
    {
        return array_merge(parent::createPayloadArray($job, $queue, $data), [
            'queue' => $this->getQueue($queue),
        ]);
    }
530471
protected function expectsJobs($jobs)
    {
        $jobs = is_array($jobs) ? $jobs : func_get_args();

        $this->withoutJobs();

        $this->beforeApplicationDestroyed(function () use ($jobs) {
            $dispatched = $this->getDispatchedJobs($jobs);

            $this->assertEmpty(
                $jobsNotDispatched = array_diff($jobs, $dispatched),
                'These expected jobs were not dispatched: ['.implode(', ', $jobsNotDispatched).']'
            );
        });

        return $this;
    }
560735
public function initializeFromJob(Aoe_Scheduler_Model_Job $job)
    {
        $this->setJobCode($job->getJobCode());
        $this->setCronExpr($job->getCronExpression());
        $this->setStatus(Aoe_Scheduler_Model_Schedule::STATUS_PENDING);
        return $this;
    }
412606
protected function retryJob($job)
    {
        $this->laravel['queue']->connection($job->connection)->pushRaw(
            $this->resetAttempts($job->payload), $job->queue
        );
    }
541118
protected function storeSnapshotForJob($job)
    {
        $data = $this->baseSnapshotData($key = 'job:'.$job);

        $this->connection()->zadd(
            'snapshot:'.$key, $time = Chronos::now()->getTimestamp(), json_encode([
                'throughput' => $data['throughput'],
                'runtime' => $data['runtime'],
                'time' => $time,
            ])
        );

        $this->connection()->zremrangebyrank(
            'snapshot:'.$key, 0, -25
        );
    }
360127
public function createPayload()
    {
        $payload = $this->extras;

        $payload['job'] = $this->job;
        $payload['data'] = $this->data;

        // Create special payload if it is a Closure
        if ($this->job instanceof \Closure) {
            $payload['closure'] = serialize(new SerializableClosure($this->job));
            $payload['job'] = $this->closureClass;
        }

        return $payload;
    }
689906
protected function addJobToQueue(string $jobName, string $payload = '') : string
    {
        if (!isset($this->jobQueues[$jobName])) {
            $this->jobQueues[$jobName] = [];
        }
        $jobId = $this->getJobId();
        array_push($this->jobQueues[$jobName], [
            'job_id' => $jobId,
            'payload' => $payload
        ]);
        $this->jobsInQueue++;
        return $jobId;
    }
447042
public function put($job)
    {
        $job['id'] = $this->redis->incr("job_id_sequence");
        $this->redis->lpush("job_queue", serialize($job));
        return $job['id'];
    }