search job in jobs

@param string $job
@return mixed
344366
public function jobExists($job = '')
    {
        $process = new Process('crontab -l');
        $process->run();

        $output = ($process->getIncrementalOutput());

        $jobs = array_filter(explode(PHP_EOL, $output), function($line) {
            return '' != trim($line);
        });

        return is_array($jobs) ?  array_search($job, $jobs) : false;
    }
1231290
public static function for($job)
    {
        if ($tags = static::extractExplicitTags($job)) {
            return $tags;
        }

        return static::modelsFor(static::targetsFor($job))->map(function ($model) {
            return get_class($model).':'.$model->getKey();
        })->all();
    }
910473
public function add(Job $job)
    {
        $jobClass = new \ReflectionClass($job);
        $name = $jobClass->getName();
        $object = serialize($job);
        $jobId = $this->broker->put(['object' => $object, 'class' => $name]);
        $this->broker->setStatus($jobId,
            ['status' => Job::STATUS_QUEUED, 'queued'=> date(DATE_RFC3339_EXTENDED)]
        );
        return $jobId;
    }
1185161
public function getJob($jobName)
    {
        $jobName = $this->jobPrefix . $jobName;

        foreach ($this->workers as $worker) {

            if (is_array($worker['jobs'])) {

                foreach ($worker['jobs'] as $job) {

                    if ($jobName === $job['realCallableName']) {

                        $worker['job'] = $job;

                        return $worker;
                    }
                }
            }
        }

        throw new JobDoesNotExistException();
    }
714790
protected function markJobAsReserved($job)
    {
        $this->database->createCommand()->update(
            $this->table, [
            'reserved_at' => $job->touch(),
            'attempts' => $job->increment(),
            ], [
            'id' => $job->id
            ]
        )->execute();

        return $job;
    }
600963
public function do_job($job) {

        static $objects;

        if ($objects===null) $objects = array();

        $w = $job->workload();

        $h = $job->handle();

        $job_name = $job->functionName();

        if ($this->prefix) {
            $func = $this->prefix.$job_name;
        } else {
            $func = $job_name;
        }

        if (empty($objects[$job_name]) && !function_exists($func) && !class_exists($func, false)) {

            if (!isset($this->functions[$job_name])) {
                $this->log("Function $func is not a registered job name");
                return;
            }

            require_once $this->functions[$job_name]["path"];

            if (class_exists($func) && method_exists($func, "run")) {

                $this->log("Creating a $func object", GearmanManager::LOG_LEVEL_WORKER_INFO);
                $ns_func = "\\$func";
                $objects[$job_name] = new $ns_func();

            } elseif (!function_exists($func)) {

                $this->log("Function $func not found");
                return;
            }

        }

        $this->log("($h) Starting Job: $job_name", GearmanManager::LOG_LEVEL_WORKER_INFO);

        $this->log("($h) Workload: $w", GearmanManager::LOG_LEVEL_DEBUG);

        $log = array();

        /**
         * Run the real function here
         */
        if (isset($objects[$job_name])) {
            $this->log("($h) Calling object for $job_name.", GearmanManager::LOG_LEVEL_DEBUG);
            $result = $objects[$job_name]->run($job, $log);
        } elseif (function_exists($func)) {
            $this->log("($h) Calling function for $job_name.", GearmanManager::LOG_LEVEL_DEBUG);
            $result = $func($job, $log);
        } else {
            $this->log("($h) FAILED to find a function or class for $job_name.", GearmanManager::LOG_LEVEL_INFO);
        }

        if (!empty($log)) {
            foreach ($log as $l) {

                if (!is_scalar($l)) {
                    $l = explode("\n", trim(print_r($l, true)));
                } elseif (strlen($l) > 256) {
                    $l = substr($l, 0, 256)."...(truncated)";
                }

                if (is_array($l)) {
                    foreach ($l as $ln) {
                        $this->log("($h) $ln", GearmanManager::LOG_LEVEL_WORKER_INFO);
                    }
                } else {
                    $this->log("($h) $l", GearmanManager::LOG_LEVEL_WORKER_INFO);
                }

            }
        }

        $result_log = $result;

        if (!is_scalar($result_log)) {
            $result_log = explode("\n", trim(print_r($result_log, true)));
        } elseif (strlen($result_log) > 256) {
            $result_log = substr($result_log, 0, 256)."...(truncated)";
        }

        if (is_array($result_log)) {
            foreach ($result_log as $ln) {
                $this->log("($h) $ln", GearmanManager::LOG_LEVEL_DEBUG);
            }
        } else {
            $this->log("($h) $result_log", GearmanManager::LOG_LEVEL_DEBUG);
        }

        /**
         * Workaround for PECL bug #17114
         * http://pecl.php.net/bugs/bug.php?id=17114
         */
        $type = gettype($result);
        settype($result, $type);


        $this->job_execution_count++;

        return $result;

    }
913486
protected function getNextJob( $connection, $queue )
	{
		if ( is_null( $queue ) )
			return $connection->pop();

		foreach ( explode( ',', $queue ) as $queue )
			if ( !is_null( $job = $connection->pop( $queue ) ) )
				return $job;

		return null;
	}
748865
public function getJobStatus($job)
    {
        $jobId = Utilities::getEntityId(
            $job,
            'WindowsAzure\MediaServices\Models\Job'
        );
        $jobIdEncoded = urlencode($jobId);

        $method = Resources::HTTP_GET;
        $headers = [];
        $postParams = [];
        $queryParams = [];
        $path = "Jobs('{$jobIdEncoded}')/State";
        $statusCode = Resources::STATUS_OK;

        $response = $this->sendHttp(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            $statusCode
        );

        return strip_tags($response->getBody());
    }
666343
public function dispatchJob($job, $data = [], $handler = 'handler')
    {
        if ($this->isSingle()) {
            if (!is_object($job)) {
                $job = new $job;
            }
            return call_user_func_array([$job, $handler], ['data' => $data]);
        }

        return null;
    }
624287
public function getJob($jobId)
    {
        $url = parse_url($this->getBaseUrl());
        return $this->get("https://{$url['host']}/queue/job/{$jobId}")->send()->json();
    }
526679
public function delete(JobInterface $job)
    {
        if ($job->isRunOnce()) {
            $this->getCache()->delete(self::CACHE_JOB.get_class($job));
        }
        return $job->getBeanstalkJob()->delete();
    }
1129326
public function delete(Job $job)
    {
        $result = false;
        try {
            $res = $this->_queue->deleteMessage($job->getInstance()->getReceiptHandle());
            $result = $res->isSucceed();
        } catch (\Exception $e) {
            $this->eventsManager->fire('listener:logger', $this, '删除Queue消息失败:' . $e->getMessage());
        } finally {
            return $result;
        }
    }
1090252
public function cancelJob($job)
    {
        $jobId = Utilities::getEntityId(
            $job,
            'WindowsAzure\MediaServices\Models\Job'
        );
        $jobIdEncoded = urlencode($jobId);

        $method = Resources::HTTP_GET;
        $headers = [];
        $postParams = [];
        $queryParams = [];
        $path = "CancelJob?jobid='{$jobIdEncoded}'";
        $statusCode = Resources::STATUS_NO_CONTENT;

        $this->sendHttp(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            $statusCode
        );
    }
655076
protected function executeJob(Job $job): ?\Throwable
    {
        try {
            $this->jobExecutor->executeJob($job, $this->retryLimit);
        } catch (\Throwable $e) {
            return $e;
        }

        return null;
    }
213422
protected static function extractEvent($job)
    {
        return isset($job->data[0]) && is_object($job->data[0])
                        ? $job->data[0]
                        : new stdClass;
    }
467769
public function transform(Job $job)
    {
        return [
            'createdAt' => $job->created_at->toW3cString(),
            'memberIds' => $job->members->pluck('id'),
            'memberName' => (count($job->members) > 0) ? $job->members->first()->user->name : null,
            'memberTagIds' => $job->member_tags->pluck('id'),
            'memberTagNames' => (count($job->member_tags) > 0)
                ? implode(', ', $job->member_tags->pluck('name')->toArray()) : null,
            'id' => $job->id,
            'locationId' => $job->location_id,
            'locationName' => is_null($job->location_id) ? null : $job->location->name,
            'start' => $job->start->toW3cString(),
            'updatedAt' => $job->updated_at->toW3cString(),
        ];
    }
79114
public function getMessageByJob($job, array $data = [])
    {
        $message = new QueueMessage();

        $job = $this->createJobInstance($job);

        $data['class'] = get_class($job);

        $message->setName($job->getName());
        $message->setJob(serialize($job));
        $message->setData($data);

        return $message;
    }