Run the worker instance.

@param  string  $connection
@param  string  $queue
@param  int  $delay
@param  int  $memory
@param  bool  $daemon
@return array
509167
protected function runWorker($connection, $queue, $delay, $memory, $daemon = false)
	{
		$this->worker->setDaemonExceptionHandler(
			$this->laravel['Illuminate\Contracts\Debug\ExceptionHandler']
		);

		if ($daemon) {
			$this->worker->setCache($this->laravel['cache']->driver());

			return $this->worker->daemon(
				$connection, $queue, $delay, $memory,
				$this->option('sleep'), $this->option('tries')
			);
		}

		return $this->worker->pop(
			$connection, $queue, $delay,
			$this->option('sleep'), $this->option('tries')
		);
	}
1268008
public function later($delay, $job, $data = '', $queue = null)
    {
        return $this->push($job, $data, $queue);
    }
85277
protected function runWorker($connection, $queue)
    {
        $this->worker->setCache($this->laravel['cache']->driver());

        return $this->worker->{$this->option('once') ? 'runNextJob' : 'daemon'}(
            $connection, $queue, $this->gatherWorkerOptions()
        );
    }
680306
public function initConnection(Connection $connection)
    {
        /** @var $pdo PDO */
        $pdo = $connection->getWrappedConnection();
        $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
        $params = $connection->getParams();
        if (!isset($params['charset'])) {
            throw new RuntimeException("No connection charset specified");
        }
        $pdo->exec('SET NAMES ' . $pdo->quote($params['charset']));
    }
1360684
public function pop( $connectionName, $queue = null, $delay = 0, $sleep = 3, $maxTries = 0 )
	{
		try
		{
			$connection = $this->manager->connection( $connectionName );

			$job = $this->getNextJob( $connection, $queue );

			// If we're able to pull a job off of the stack, we will process it and
			// then immediately return back out. If there is no job on the queue
			// we will "sleep" the worker for the specified number of seconds.
			if ( !is_null( $job ) )
				return $this->process( $this->manager->getName( $connectionName ), $job, $maxTries, $delay );
		}
		catch ( Exception $e )
		{
			if ( $this->exceptions )
				$this->exceptions->report( $e );
		}

		$this->sleep( $sleep );

		return ['job' => null, 'failed' => false];
	}
1264179
protected function runWorker($connection, $queue)
    {
        $this->worker->setCache(Zilf::$container->getShare('cache')->driver());

        return $this->worker->{$this->option('once') ? 'runNextJob' : 'daemon'}(
            $this,
            $connection, $queue, $this->gatherWorkerOptions()
        );
    }
1002825
public function later($delay, $job, $data = '', $queue = null)
	{
		$payload = $this->createPayload($job, $data);

		$this->redis->zadd($this->getQueue($queue).':delayed', $this->getTime() + $delay, $payload);
	}
404330
protected static function build( $connection ) {
		$connections = static::connections();

		if ( empty( $connections[ $connection ] ) ) {
			throw new ConnectionNotFoundException();
		}

		static::$instances[ $connection ] = new Queue( $connections[ $connection ] );

		return static::$instances[ $connection ];
	}
565877
public function push($job, array $data = null, $queue = null)
    {
        if (false !== ($delay = \Resque::getConfig('default.jobs.delay', false))) {
            return $this->later($delay, $job, $data, $queue);
        }

        return Job::create($this->getQueue($queue), $job, $data);
    }
745670
public function reserved($connection, $queue, JobPayload $payload)
    {
        $time = str_replace(',', '.', microtime(true));

        $this->connection()->hmset(
            $payload->id(), [
                'status' => 'reserved',
                'payload' => $payload->value,
                'updated_at' => $time,
                'reserved_at' => $time,
            ]
        );
    }
299922
final public function run(Connection $connection)
    {
        $start = microtime(true);

        foreach (QueryBuilder::getBeforeRun() as $callback) {

            // function(\UniMapper\Query $query)
            $callback($this);
        }

        $result = $this->onExecute($connection);
        foreach (QueryBuilder::getAfterRun() as $callback) {

            // function(\UniMapper\Query $query, mixed $result, int $elapsed)
            $callback($this, $result, microtime(true) - $start);
        }

        return $result;
    }
351682
public function later($delay, $job, $data = '', $queue = null)
    {
        $payload = $this->createPayload($job, $data);

        $delay = $this->getSeconds($delay);

        $this->getConnection()->zAdd($this->getQueue($queue) . ':delayed', $this->getTime() + $delay, $payload);

        return Arr::get(json_decode($payload, true), 'id');
    }
9969
protected function raiseAfterJobEvent($connection, Job $job)
    {
        if (isset($this->events)) {
            $this->events->dispatch('nova.queue.processed', array($connection, $job));
        }
    }
1278003
protected function executePipeline(ConnectionInterface $connection, \SplQueue $commands)
    {
        foreach ($commands as $command) {
            $connection->writeRequest($command);
        }

        $responses = array();
        $exceptions = $this->throwServerExceptions();

        while (!$commands->isEmpty()) {
            $command = $commands->dequeue();
            $response = $connection->readResponse($command);

            if (!$response instanceof ResponseInterface) {
                $responses[] = $command->parseResponse($response);
            } elseif ($response instanceof ErrorResponseInterface && $exceptions) {
                $this->exception($connection, $response);
            } else {
                $responses[] = $response;
            }
        }

        return $responses;
    }
1203231
protected function getNextJob($connection, $queue)
    {
        try {
            foreach (explode(',', $queue) as $queue) {
                if (!is_null($job = $connection->pop($queue))) {
                    return $job;
                }
            }
        } catch (Exception $e) {
            $this->report($e);

            $this->stopWorkerIfLostConnection($e);

            $this->sleep(1);
        } catch (Throwable $e) {
            $e = new FatalThrowableError($e);
            $this->report($e);

            $this->stopWorkerIfLostConnection($e);

            $this->sleep(1);
        }
    }
628919
public function releaseJob($id, $delay = 0)
    {
        $payload = $this->getPayload($id);

        if ($payload[self::JOB_PAYLOAD_STATE] !== self::STATE_RESERVED) {
            throw new QueueException(' Cannot release state unsupported! ' . $payload[self::JOB_PAYLOAD_STATE]);
        }

        $keyReady = $this->getKeyReady($payload[self::JOB_PAYLOAD_QUEUE]);
        $keyDelayed = $this->getKeyDelayed($payload[self::JOB_PAYLOAD_QUEUE]);
        $keyReserved = $this->getKeyReserved($payload[self::JOB_PAYLOAD_QUEUE]);
        $redisJobNamespace = $this->getRedisJobNamespace();

        $result = $this->getRedis()->transaction(
            function ($tx) use ($id, $payload, $delay, $keyReady, $keyDelayed, $keyReserved, $redisJobNamespace) {
                /** @var $tx \Predis\Client */
                $tx->zrem($keyReserved, $id);

                $payload = self::buildPayload($payload[self::JOB_PAYLOAD_QUEUE], (($delay)
                    ? self::STATE_DELAYED
                    : self::STATE_READY
                ));
                $tx->hset($redisJobNamespace, $id, $payload);

                if ($delay == 0) {
                    $tx->rpush($keyReady, $id);
                } else {
                    $tx->zadd($keyDelayed, $this->getTime() + $delay, $id);
                }
            }
        );

        return !in_array(false, $result);
    }
270629
public function initConnection(Connection $connection)
    {
        /** @var $pdo PDO */
        $pdo = $connection->getWrappedConnection();
        $this->fkSupported = version_compare('3.6.19', $pdo->getAttribute(PDO::ATTR_SERVER_VERSION)) < 0;
        $pdo->exec($this->buildEnableForeignKeysQuery());
    }