芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/tblonline.org/vendor/laravel/framework/src/Illuminate/Queue/SqsQueue.php
sqs = $sqs; $this->prefix = $prefix; $this->default = $default; $this->suffix = $suffix; $this->dispatchAfterCommit = $dispatchAfterCommit; } /** * Get the size of the queue. * * @param string|null $queue * @return int */ public function size($queue = null) { $response = $this->sqs->getQueueAttributes([ 'QueueUrl' => $this->getQueue($queue), 'AttributeNames' => ['ApproximateNumberOfMessages'], ]); $attributes = $response->get('Attributes'); return (int) $attributes['ApproximateNumberOfMessages']; } /** * Push a new job onto the queue. * * @param string $job * @param mixed $data * @param string|null $queue * @return mixed */ public function push($job, $data = '', $queue = null) { return $this->enqueueUsing( $job, $this->createPayload($job, $queue ?: $this->default, $data), $queue, null, function ($payload, $queue) { return $this->pushRaw($payload, $queue); } ); } /** * Push a raw payload onto the queue. * * @param string $payload * @param string|null $queue * @param array $options * @return mixed */ public function pushRaw($payload, $queue = null, array $options = []) { return $this->sqs->sendMessage([ 'QueueUrl' => $this->getQueue($queue), 'MessageBody' => $payload, ])->get('MessageId'); } /** * Push a new job onto the queue after a delay. * * @param \DateTimeInterface|\DateInterval|int $delay * @param string $job * @param mixed $data * @param string|null $queue * @return mixed */ public function later($delay, $job, $data = '', $queue = null) { return $this->enqueueUsing( $job, $this->createPayload($job, $queue ?: $this->default, $data), $queue, $delay, function ($payload, $queue, $delay) { return $this->sqs->sendMessage([ 'QueueUrl' => $this->getQueue($queue), 'MessageBody' => $payload, 'DelaySeconds' => $this->secondsUntil($delay), ])->get('MessageId'); } ); } /** * Pop the next job off of the queue. * * @param string|null $queue * @return \Illuminate\Contracts\Queue\Job|null */ public function pop($queue = null) { $response = $this->sqs->receiveMessage([ 'QueueUrl' => $queue = $this->getQueue($queue), 'AttributeNames' => ['ApproximateReceiveCount'], ]); if (! is_null($response['Messages']) && count($response['Messages']) > 0) { return new SqsJob( $this->container, $this->sqs, $response['Messages'][0], $this->connectionName, $queue ); } } /** * Delete all of the jobs from the queue. * * @param string $queue * @return int */ public function clear($queue) { return tap($this->size($queue), function () use ($queue) { $this->sqs->purgeQueue([ 'QueueUrl' => $this->getQueue($queue), ]); }); } /** * Get the queue or return the default. * * @param string|null $queue * @return string */ public function getQueue($queue) { $queue = $queue ?: $this->default; return filter_var($queue, FILTER_VALIDATE_URL) === false ? rtrim($this->prefix, '/').'/'.Str::finish($queue, $this->suffix) : $queue; } /** * Get the underlying SQS instance. * * @return \Aws\Sqs\SqsClient */ public function getSqs() { return $this->sqs; } }