Skip to content

Commit 501d9a3

Browse files
committed
Small refactor
1 parent c35c228 commit 501d9a3

File tree

4 files changed

+19
-47
lines changed

4 files changed

+19
-47
lines changed

AUTHORS

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
Serghei Iakovlev <[email protected]>
2-
Stuart Carnie <[email protected]>
1+
Serhii Osadchyi <[email protected]>

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2018 PDFfiller
3+
Copyright (c) 2018-2019 PDFfiller
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
],
1717
"require": {
1818
"ext-json": "*",
19-
"pdffiller/qless-php": "3.3.0"
19+
"pdffiller/qless-php": "3.4.0"
2020
},
2121
"require-dev": {
2222
"illuminate/events": "5.6.*|5.7.*",

src/Queue/QlessQueue.php

Lines changed: 16 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Contracts\Queue\Queue as QueueContract;
66
use Illuminate\Queue\InvalidPayloadException;
77
use Illuminate\Queue\Queue;
8+
use LaravelQless\Contracts\JobHandler;
89
use LaravelQless\Job\QlessJob;
910
use Qless\Client;
1011
use Qless\Topics\Topic;
@@ -22,20 +23,15 @@ class QlessQueue extends Queue implements QueueContract
2223
*/
2324
private $connect;
2425

25-
/**
26-
* @var array
27-
*/
28-
private $config;
29-
3026
/**
3127
* @var string
3228
*/
33-
protected $connectionName;
29+
private $defaultQueue;
3430

3531
/**
36-
* @var string
32+
* @var array
3733
*/
38-
protected $defaultQueue;
34+
private $config;
3935

4036
/**
4137
* QlessQueue constructor.
@@ -45,7 +41,7 @@ class QlessQueue extends Queue implements QueueContract
4541
public function __construct(Client $connect, array $config)
4642
{
4743
$this->connect = $connect;
48-
$this->defaultQueue = $config['queue'] ?? '';
44+
$this->defaultQueue = $config['queue'] ?? null;
4945
$this->connectionName = $config['connection'] ?? '';
5046
$this->config = $config;
5147
}
@@ -56,7 +52,7 @@ public function __construct(Client $connect, array $config)
5652
* @param string $queue
5753
* @return int
5854
*/
59-
public function size($queue = null)
55+
public function size($queue = null): int
6056
{
6157
return $this->getConnection()->length($queue);
6258
}
@@ -126,7 +122,7 @@ public function later($delay, $job, $data = '', $queueName = null)
126122
* @param string $queueName
127123
* @return string
128124
*/
129-
public function recur(int $interval, string $job, array $data, ?string $queueName = null)
125+
public function recur(int $interval, string $job, array $data, ?string $queueName = null): string
130126
{
131127
/** @var \Qless\Queues\Queue $queue */
132128
$queue = $this->getConnection()->queues[$queueName];
@@ -142,8 +138,6 @@ public function recur(int $interval, string $job, array $data, ?string $queueNam
142138
*/
143139
public function pop($queueName = null)
144140
{
145-
$queueName = $queueName ?? $this->defaultQueue;
146-
147141
/** @var \Qless\Queues\Queue $queue */
148142
$queue = $this->getConnection()->queues[$queueName];
149143

@@ -156,9 +150,11 @@ public function pop($queueName = null)
156150
$payload = $this->makePayload($job->getKlass(), $job->getData());
157151

158152
return new QlessJob(
153+
$this->container,
154+
$this,
155+
app()->make(JobHandler::class),
159156
$job,
160-
$payload,
161-
$this->getConnectionName()
157+
$payload
162158
);
163159
}
164160

@@ -193,15 +189,15 @@ public function unSubscribe(string $topic, string $queueName = null): bool
193189
}
194190

195191
/**
196-
* @param string $topic
192+
* @param string $topicName
197193
* @param string $job
198194
* @param array $data
199195
* @param array $options
200-
* @return array
196+
* @return array|string
201197
*/
202-
public function pushToTopic(string $topic, string $job, array $data = [], array $options = []): array
198+
public function pushToTopic(string $topicName, string $job, array $data = [], array $options = []): array
203199
{
204-
$topic = new Topic($topic, $this->getConnection());
200+
$topic = new Topic($topicName, $this->getConnection());
205201

206202
return $topic->put(
207203
$job,
@@ -218,7 +214,7 @@ public function pushToTopic(string $topic, string $job, array $data = [], array
218214
* @param array $options
219215
* @return string
220216
*/
221-
protected function makePayload(string $job, $data, $options = [])
217+
protected function makePayload(string $job, $data, $options = []): string
222218
{
223219
$payload = json_encode([
224220
'displayName' => explode('@', $job)[0],
@@ -237,29 +233,6 @@ protected function makePayload(string $job, $data, $options = [])
237233
return $payload;
238234
}
239235

240-
/**
241-
* Get the connection name for the queue.
242-
*
243-
* @return string
244-
*/
245-
public function getConnectionName(): string
246-
{
247-
return $this->connectionName;
248-
}
249-
250-
/**
251-
* Set the connection name for the queue.
252-
*
253-
* @param string $name
254-
* @return $this
255-
*/
256-
public function setConnectionName($name): self
257-
{
258-
$this->connectionName = $name;
259-
260-
return $this;
261-
}
262-
263236
/**
264237
* @return Client
265238
*/

0 commit comments

Comments
 (0)