Skip to content

Commit 7fc1e85

Browse files
committed
[redis] Do not use deprecated classes.
1 parent 3676e5c commit 7fc1e85

20 files changed

+99
-99
lines changed

pkg/redis/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Total Downloads](https://poser.pugx.org/enqueue/redis/d/total.png)](https://packagist.org/packages/enqueue/redis)
66
[![Latest Stable Version](https://poser.pugx.org/enqueue/redis/version.png)](https://packagist.org/packages/enqueue/redis)
77

8-
This is an implementation of PSR specification. It allows you to send and consume message with Redis store as a broker.
8+
This is an implementation of Queue Interop specification. It allows you to send and consume message with Redis store as a broker.
99

1010
## Resources
1111

pkg/redis/RedisConnectionFactory.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
namespace Enqueue\Redis;
66

77
use Enqueue\Dsn\Dsn;
8-
use Interop\Queue\PsrConnectionFactory;
9-
use Interop\Queue\PsrContext;
8+
use Interop\Queue\ConnectionFactory;
9+
use Interop\Queue\Context;
1010

11-
class RedisConnectionFactory implements PsrConnectionFactory
11+
class RedisConnectionFactory implements ConnectionFactory
1212
{
1313
/**
1414
* @var array
@@ -80,7 +80,7 @@ public function __construct($config = 'redis:')
8080
/**
8181
* @return RedisContext
8282
*/
83-
public function createContext(): PsrContext
83+
public function createContext(): Context
8484
{
8585
if ($this->config['lazy']) {
8686
return new RedisContext(function () {

pkg/redis/RedisConsumer.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
namespace Enqueue\Redis;
66

7-
use Interop\Queue\InvalidMessageException;
8-
use Interop\Queue\PsrConsumer;
9-
use Interop\Queue\PsrMessage;
10-
use Interop\Queue\PsrQueue;
7+
use Interop\Queue\Consumer;
8+
use Interop\Queue\Exception\InvalidMessageException;
9+
use Interop\Queue\Message;
10+
use Interop\Queue\Queue;
1111

12-
class RedisConsumer implements PsrConsumer
12+
class RedisConsumer implements Consumer
1313
{
1414
/**
1515
* @var RedisDestination
@@ -30,15 +30,15 @@ public function __construct(RedisContext $context, RedisDestination $queue)
3030
/**
3131
* @return RedisDestination
3232
*/
33-
public function getQueue(): PsrQueue
33+
public function getQueue(): Queue
3434
{
3535
return $this->queue;
3636
}
3737

3838
/**
3939
* @return RedisMessage
4040
*/
41-
public function receive(int $timeout = 0): ?PsrMessage
41+
public function receive(int $timeout = 0): ?Message
4242
{
4343
$timeout = (int) ($timeout / 1000);
4444
if (empty($timeout)) {
@@ -59,7 +59,7 @@ public function receive(int $timeout = 0): ?PsrMessage
5959
/**
6060
* @return RedisMessage
6161
*/
62-
public function receiveNoWait(): ?PsrMessage
62+
public function receiveNoWait(): ?Message
6363
{
6464
if ($result = $this->getRedis()->rpop($this->queue->getName())) {
6565
return RedisMessage::jsonUnserialize($result->getMessage());
@@ -71,15 +71,15 @@ public function receiveNoWait(): ?PsrMessage
7171
/**
7272
* @param RedisMessage $message
7373
*/
74-
public function acknowledge(PsrMessage $message): void
74+
public function acknowledge(Message $message): void
7575
{
7676
// do nothing. redis transport always works in auto ack mode
7777
}
7878

7979
/**
8080
* @param RedisMessage $message
8181
*/
82-
public function reject(PsrMessage $message, bool $requeue = false): void
82+
public function reject(Message $message, bool $requeue = false): void
8383
{
8484
InvalidMessageException::assertMessageInstanceOf($message, RedisMessage::class);
8585

pkg/redis/RedisContext.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44

55
namespace Enqueue\Redis;
66

7-
use Interop\Queue\InvalidDestinationException;
8-
use Interop\Queue\PsrConsumer;
9-
use Interop\Queue\PsrContext;
10-
use Interop\Queue\PsrDestination;
11-
use Interop\Queue\PsrMessage;
12-
use Interop\Queue\PsrProducer;
13-
use Interop\Queue\PsrQueue;
14-
use Interop\Queue\PsrSubscriptionConsumer;
15-
use Interop\Queue\PsrTopic;
16-
use Interop\Queue\TemporaryQueueNotSupportedException;
17-
18-
class RedisContext implements PsrContext
7+
use Interop\Queue\Consumer;
8+
use Interop\Queue\Context;
9+
use Interop\Queue\Destination;
10+
use Interop\Queue\Exception\InvalidDestinationException;
11+
use Interop\Queue\Exception\TemporaryQueueNotSupportedException;
12+
use Interop\Queue\Message;
13+
use Interop\Queue\Producer;
14+
use Interop\Queue\Queue;
15+
use Interop\Queue\SubscriptionConsumer;
16+
use Interop\Queue\Topic;
17+
18+
class RedisContext implements Context
1919
{
2020
/**
2121
* @var Redis
@@ -50,31 +50,31 @@ public function __construct($redis)
5050
/**
5151
* @return RedisMessage
5252
*/
53-
public function createMessage(string $body = '', array $properties = [], array $headers = []): PsrMessage
53+
public function createMessage(string $body = '', array $properties = [], array $headers = []): Message
5454
{
5555
return new RedisMessage($body, $properties, $headers);
5656
}
5757

5858
/**
5959
* @return RedisDestination
6060
*/
61-
public function createTopic(string $topicName): PsrTopic
61+
public function createTopic(string $topicName): Topic
6262
{
6363
return new RedisDestination($topicName);
6464
}
6565

6666
/**
6767
* @return RedisDestination
6868
*/
69-
public function createQueue(string $queueName): PsrQueue
69+
public function createQueue(string $queueName): Queue
7070
{
7171
return new RedisDestination($queueName);
7272
}
7373

7474
/**
7575
* @param RedisDestination $queue
7676
*/
77-
public function deleteQueue(PsrQueue $queue): void
77+
public function deleteQueue(Queue $queue): void
7878
{
7979
InvalidDestinationException::assertDestinationInstanceOf($queue, RedisDestination::class);
8080

@@ -84,22 +84,22 @@ public function deleteQueue(PsrQueue $queue): void
8484
/**
8585
* @param RedisDestination $topic
8686
*/
87-
public function deleteTopic(PsrTopic $topic): void
87+
public function deleteTopic(Topic $topic): void
8888
{
8989
InvalidDestinationException::assertDestinationInstanceOf($topic, RedisDestination::class);
9090

9191
$this->getRedis()->del($topic->getName());
9292
}
9393

94-
public function createTemporaryQueue(): PsrQueue
94+
public function createTemporaryQueue(): Queue
9595
{
9696
throw TemporaryQueueNotSupportedException::providerDoestNotSupportIt();
9797
}
9898

9999
/**
100100
* @return RedisProducer
101101
*/
102-
public function createProducer(): PsrProducer
102+
public function createProducer(): Producer
103103
{
104104
return new RedisProducer($this->getRedis());
105105
}
@@ -109,7 +109,7 @@ public function createProducer(): PsrProducer
109109
*
110110
* @return RedisConsumer
111111
*/
112-
public function createConsumer(PsrDestination $destination): PsrConsumer
112+
public function createConsumer(Destination $destination): Consumer
113113
{
114114
InvalidDestinationException::assertDestinationInstanceOf($destination, RedisDestination::class);
115115

@@ -119,15 +119,15 @@ public function createConsumer(PsrDestination $destination): PsrConsumer
119119
/**
120120
* @return RedisSubscriptionConsumer
121121
*/
122-
public function createSubscriptionConsumer(): PsrSubscriptionConsumer
122+
public function createSubscriptionConsumer(): SubscriptionConsumer
123123
{
124124
return new RedisSubscriptionConsumer($this);
125125
}
126126

127127
/**
128128
* @param RedisDestination $queue
129129
*/
130-
public function purgeQueue(PsrQueue $queue): void
130+
public function purgeQueue(Queue $queue): void
131131
{
132132
$this->getRedis()->del($queue->getName());
133133
}

pkg/redis/RedisDestination.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
namespace Enqueue\Redis;
66

7-
use Interop\Queue\PsrQueue;
8-
use Interop\Queue\PsrTopic;
7+
use Interop\Queue\Queue;
8+
use Interop\Queue\Topic;
99

10-
class RedisDestination implements PsrQueue, PsrTopic
10+
class RedisDestination implements Queue, Topic
1111
{
1212
/**
1313
* @var string

pkg/redis/RedisMessage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
namespace Enqueue\Redis;
66

7-
use Interop\Queue\PsrMessage;
7+
use Interop\Queue\Message;
88

9-
class RedisMessage implements PsrMessage, \JsonSerializable
9+
class RedisMessage implements Message, \JsonSerializable
1010
{
1111
/**
1212
* @var string

pkg/redis/RedisProducer.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
namespace Enqueue\Redis;
66

7-
use Interop\Queue\InvalidDestinationException;
8-
use Interop\Queue\InvalidMessageException;
9-
use Interop\Queue\PsrDestination;
10-
use Interop\Queue\PsrMessage;
11-
use Interop\Queue\PsrProducer;
7+
use Interop\Queue\Destination;
8+
use Interop\Queue\Exception\InvalidDestinationException;
9+
use Interop\Queue\Exception\InvalidMessageException;
10+
use Interop\Queue\Message;
11+
use Interop\Queue\Producer;
1212

13-
class RedisProducer implements PsrProducer
13+
class RedisProducer implements Producer
1414
{
1515
/**
1616
* @var Redis
@@ -29,7 +29,7 @@ public function __construct(Redis $redis)
2929
* @param RedisDestination $destination
3030
* @param RedisMessage $message
3131
*/
32-
public function send(PsrDestination $destination, PsrMessage $message): void
32+
public function send(Destination $destination, Message $message): void
3333
{
3434
InvalidDestinationException::assertDestinationInstanceOf($destination, RedisDestination::class);
3535
InvalidMessageException::assertMessageInstanceOf($message, RedisMessage::class);
@@ -40,7 +40,7 @@ public function send(PsrDestination $destination, PsrMessage $message): void
4040
/**
4141
* @return RedisProducer
4242
*/
43-
public function setDeliveryDelay(int $deliveryDelay = null): PsrProducer
43+
public function setDeliveryDelay(int $deliveryDelay = null): Producer
4444
{
4545
if (null === $deliveryDelay) {
4646
return $this;
@@ -57,7 +57,7 @@ public function getDeliveryDelay(): ?int
5757
/**
5858
* @return RedisProducer
5959
*/
60-
public function setPriority(int $priority = null): PsrProducer
60+
public function setPriority(int $priority = null): Producer
6161
{
6262
if (null === $priority) {
6363
return $this;
@@ -74,7 +74,7 @@ public function getPriority(): ?int
7474
/**
7575
* @return RedisProducer
7676
*/
77-
public function setTimeToLive(int $timeToLive = null): PsrProducer
77+
public function setTimeToLive(int $timeToLive = null): Producer
7878
{
7979
if (null === $timeToLive) {
8080
return $this;

pkg/redis/RedisSubscriptionConsumer.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
namespace Enqueue\Redis;
66

7-
use Interop\Queue\PsrConsumer;
8-
use Interop\Queue\PsrSubscriptionConsumer;
7+
use Interop\Queue\Consumer;
8+
use Interop\Queue\SubscriptionConsumer;
99

10-
class RedisSubscriptionConsumer implements PsrSubscriptionConsumer
10+
class RedisSubscriptionConsumer implements SubscriptionConsumer
1111
{
1212
/**
1313
* @var RedisContext
@@ -52,8 +52,8 @@ public function consume(int $timeout = 0): void
5252

5353
/**
5454
* @var string
55-
* @var PsrConsumer $consumer
56-
* @var callable $processor
55+
* @var Consumer $consumer
56+
* @var callable $processor
5757
*/
5858
$result = $this->context->getRedis()->brpop($currentQueueNames, $timeout ?: 5);
5959
if ($result) {
@@ -81,7 +81,7 @@ public function consume(int $timeout = 0): void
8181
/**
8282
* @param RedisConsumer $consumer
8383
*/
84-
public function subscribe(PsrConsumer $consumer, callable $callback): void
84+
public function subscribe(Consumer $consumer, callable $callback): void
8585
{
8686
if (false == $consumer instanceof RedisConsumer) {
8787
throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', RedisConsumer::class, get_class($consumer)));
@@ -102,7 +102,7 @@ public function subscribe(PsrConsumer $consumer, callable $callback): void
102102
/**
103103
* @param RedisConsumer $consumer
104104
*/
105-
public function unsubscribe(PsrConsumer $consumer): void
105+
public function unsubscribe(Consumer $consumer): void
106106
{
107107
if (false == $consumer instanceof RedisConsumer) {
108108
throw new \InvalidArgumentException(sprintf('The consumer must be instance of "%s" got "%s"', RedisConsumer::class, get_class($consumer)));

pkg/redis/ServerException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Enqueue\Redis;
66

7-
use Interop\Queue\Exception;
7+
use Interop\Queue\Exception\Exception;
88

99
class ServerException extends Exception
1010
{

pkg/redis/Tests/Functional/ConsumptionUseCasesTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Enqueue\Consumption\QueueConsumer;
1010
use Enqueue\Consumption\Result;
1111
use Enqueue\Redis\RedisContext;
12-
use Interop\Queue\PsrMessage;
12+
use Interop\Queue\Message;
1313

1414
trait ConsumptionUseCasesTrait
1515
{
@@ -30,7 +30,7 @@ public function testConsumeOneMessageAndExit()
3030

3131
$queueConsumer->consume();
3232

33-
$this->assertInstanceOf(PsrMessage::class, $processor->lastProcessedMessage);
33+
$this->assertInstanceOf(Message::class, $processor->lastProcessedMessage);
3434
$this->assertEquals(__METHOD__, $processor->lastProcessedMessage->getBody());
3535
}
3636

@@ -61,10 +61,10 @@ public function testConsumeOneMessageAndSendReplyExit()
6161
$queueConsumer->bind($replyQueue, $replyProcessor);
6262
$queueConsumer->consume();
6363

64-
$this->assertInstanceOf(PsrMessage::class, $processor->lastProcessedMessage);
64+
$this->assertInstanceOf(Message::class, $processor->lastProcessedMessage);
6565
$this->assertEquals(__METHOD__, $processor->lastProcessedMessage->getBody());
6666

67-
$this->assertInstanceOf(PsrMessage::class, $replyProcessor->lastProcessedMessage);
67+
$this->assertInstanceOf(Message::class, $replyProcessor->lastProcessedMessage);
6868
$this->assertEquals(__METHOD__.'.reply', $replyProcessor->lastProcessedMessage->getBody());
6969
}
7070

0 commit comments

Comments
 (0)