Skip to content

Commit 93bb7c1

Browse files
committed
[gps] Do not use deprecated classes
1 parent 94017a2 commit 93bb7c1

12 files changed

+70
-70
lines changed

pkg/gps/GpsConnectionFactory.php

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

77
use Enqueue\Dsn\Dsn;
88
use Google\Cloud\PubSub\PubSubClient;
9-
use Interop\Queue\PsrConnectionFactory;
10-
use Interop\Queue\PsrContext;
9+
use Interop\Queue\ConnectionFactory;
10+
use Interop\Queue\Context;
1111

12-
class GpsConnectionFactory implements PsrConnectionFactory
12+
class GpsConnectionFactory implements ConnectionFactory
1313
{
1414
/**
1515
* @var array
@@ -72,7 +72,7 @@ public function __construct($config = 'gps:')
7272
/**
7373
* @return GpsContext
7474
*/
75-
public function createContext(): PsrContext
75+
public function createContext(): Context
7676
{
7777
if ($this->config['lazy']) {
7878
return new GpsContext(function () {

pkg/gps/GpsConsumer.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
namespace Enqueue\Gps;
66

77
use Google\Cloud\Core\Exception\ServiceException;
8-
use Google\Cloud\PubSub\Message;
8+
use Google\Cloud\PubSub\Message as GoogleMessage;
99
use Google\Cloud\PubSub\Subscription;
10-
use Interop\Queue\PsrConsumer;
11-
use Interop\Queue\PsrMessage;
12-
use Interop\Queue\PsrQueue;
10+
use Interop\Queue\Consumer;
11+
use Interop\Queue\Message;
12+
use Interop\Queue\Queue;
1313

14-
class GpsConsumer implements PsrConsumer
14+
class GpsConsumer implements Consumer
1515
{
1616
/**
1717
* @var GpsContext
@@ -37,15 +37,15 @@ public function __construct(GpsContext $context, GpsQueue $queue)
3737
/**
3838
* @return GpsQueue
3939
*/
40-
public function getQueue(): PsrQueue
40+
public function getQueue(): Queue
4141
{
4242
return $this->queue;
4343
}
4444

4545
/**
4646
* @return GpsMessage
4747
*/
48-
public function receive(int $timeout = 0): ?PsrMessage
48+
public function receive(int $timeout = 0): ?Message
4949
{
5050
if (0 === $timeout) {
5151
while (true) {
@@ -61,7 +61,7 @@ public function receive(int $timeout = 0): ?PsrMessage
6161
/**
6262
* @return GpsMessage
6363
*/
64-
public function receiveNoWait(): ?PsrMessage
64+
public function receiveNoWait(): ?Message
6565
{
6666
$messages = $this->getSubscription()->pull([
6767
'maxMessages' => 1,
@@ -78,7 +78,7 @@ public function receiveNoWait(): ?PsrMessage
7878
/**
7979
* @param GpsMessage $message
8080
*/
81-
public function acknowledge(PsrMessage $message): void
81+
public function acknowledge(Message $message): void
8282
{
8383
if (false == $message->getNativeMessage()) {
8484
throw new \LogicException('Native google pub/sub message required but it is empty');
@@ -90,7 +90,7 @@ public function acknowledge(PsrMessage $message): void
9090
/**
9191
* @param GpsMessage $message
9292
*/
93-
public function reject(PsrMessage $message, bool $requeue = false): void
93+
public function reject(Message $message, bool $requeue = false): void
9494
{
9595
if (false == $message->getNativeMessage()) {
9696
throw new \LogicException('Native google pub/sub message required but it is empty');
@@ -108,7 +108,7 @@ private function getSubscription(): Subscription
108108
return $this->subscription;
109109
}
110110

111-
private function convertMessage(Message $message): GpsMessage
111+
private function convertMessage(GoogleMessage $message): GpsMessage
112112
{
113113
$gpsMessage = GpsMessage::jsonUnserialize($message->data());
114114
$gpsMessage->setNativeMessage($message);

pkg/gps/GpsContext.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66

77
use Google\Cloud\Core\Exception\ConflictException;
88
use Google\Cloud\PubSub\PubSubClient;
9-
use Interop\Queue\InvalidDestinationException;
10-
use Interop\Queue\PsrConsumer;
11-
use Interop\Queue\PsrContext;
12-
use Interop\Queue\PsrDestination;
13-
use Interop\Queue\PsrMessage;
14-
use Interop\Queue\PsrProducer;
15-
use Interop\Queue\PsrQueue;
16-
use Interop\Queue\PsrSubscriptionConsumer;
17-
use Interop\Queue\PsrTopic;
18-
use Interop\Queue\PurgeQueueNotSupportedException;
19-
use Interop\Queue\SubscriptionConsumerNotSupportedException;
20-
use Interop\Queue\TemporaryQueueNotSupportedException;
21-
22-
class GpsContext implements PsrContext
9+
use Interop\Queue\Consumer;
10+
use Interop\Queue\Context;
11+
use Interop\Queue\Destination;
12+
use Interop\Queue\Exception\InvalidDestinationException;
13+
use Interop\Queue\Exception\PurgeQueueNotSupportedException;
14+
use Interop\Queue\Exception\SubscriptionConsumerNotSupportedException;
15+
use Interop\Queue\Exception\TemporaryQueueNotSupportedException;
16+
use Interop\Queue\Message;
17+
use Interop\Queue\Producer;
18+
use Interop\Queue\Queue;
19+
use Interop\Queue\SubscriptionConsumer;
20+
use Interop\Queue\Topic;
21+
22+
class GpsContext implements Context
2323
{
2424
/**
2525
* @var PubSubClient
@@ -63,36 +63,36 @@ public function __construct($client, array $options = [])
6363
/**
6464
* @return GpsMessage
6565
*/
66-
public function createMessage(string $body = '', array $properties = [], array $headers = []): PsrMessage
66+
public function createMessage(string $body = '', array $properties = [], array $headers = []): Message
6767
{
6868
return new GpsMessage($body, $properties, $headers);
6969
}
7070

7171
/**
7272
* @return GpsTopic
7373
*/
74-
public function createTopic(string $topicName): PsrTopic
74+
public function createTopic(string $topicName): Topic
7575
{
7676
return new GpsTopic($topicName);
7777
}
7878

7979
/**
8080
* @return GpsQueue
8181
*/
82-
public function createQueue(string $queueName): PsrQueue
82+
public function createQueue(string $queueName): Queue
8383
{
8484
return new GpsQueue($queueName);
8585
}
8686

87-
public function createTemporaryQueue(): PsrQueue
87+
public function createTemporaryQueue(): Queue
8888
{
8989
throw TemporaryQueueNotSupportedException::providerDoestNotSupportIt();
9090
}
9191

9292
/**
9393
* @return GpsProducer
9494
*/
95-
public function createProducer(): PsrProducer
95+
public function createProducer(): Producer
9696
{
9797
return new GpsProducer($this);
9898
}
@@ -102,7 +102,7 @@ public function createProducer(): PsrProducer
102102
*
103103
* @return GpsConsumer
104104
*/
105-
public function createConsumer(PsrDestination $destination): PsrConsumer
105+
public function createConsumer(Destination $destination): Consumer
106106
{
107107
InvalidDestinationException::assertDestinationInstanceOf($destination, GpsQueue::class);
108108

@@ -113,12 +113,12 @@ public function close(): void
113113
{
114114
}
115115

116-
public function createSubscriptionConsumer(): PsrSubscriptionConsumer
116+
public function createSubscriptionConsumer(): SubscriptionConsumer
117117
{
118118
throw SubscriptionConsumerNotSupportedException::providerDoestNotSupportIt();
119119
}
120120

121-
public function purgeQueue(PsrQueue $queue): void
121+
public function purgeQueue(Queue $queue): void
122122
{
123123
throw PurgeQueueNotSupportedException::providerDoestNotSupportIt();
124124
}

pkg/gps/GpsMessage.php

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

55
namespace Enqueue\Gps;
66

7-
use Google\Cloud\PubSub\Message;
8-
use Interop\Queue\PsrMessage;
7+
use Google\Cloud\PubSub\Message as GoogleMessage;
8+
use Interop\Queue\Message;
99

10-
class GpsMessage implements PsrMessage, \JsonSerializable
10+
class GpsMessage implements Message, \JsonSerializable
1111
{
1212
/**
1313
* @var string
@@ -30,7 +30,7 @@ class GpsMessage implements PsrMessage, \JsonSerializable
3030
private $redelivered;
3131

3232
/**
33-
* @var Message
33+
* @var GoogleMessage
3434
*/
3535
private $nativeMessage;
3636

@@ -168,12 +168,12 @@ public static function jsonUnserialize(string $json): self
168168
return new self($data['body'], $data['properties'], $data['headers']);
169169
}
170170

171-
public function getNativeMessage(): ?Message
171+
public function getNativeMessage(): ?GoogleMessage
172172
{
173173
return $this->nativeMessage;
174174
}
175175

176-
public function setNativeMessage(Message $message = null): void
176+
public function setNativeMessage(GoogleMessage $message = null): void
177177
{
178178
$this->nativeMessage = $message;
179179
}

pkg/gps/GpsProducer.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
namespace Enqueue\Gps;
66

77
use Google\Cloud\PubSub\Topic;
8-
use Interop\Queue\DeliveryDelayNotSupportedException;
9-
use Interop\Queue\InvalidDestinationException;
10-
use Interop\Queue\InvalidMessageException;
11-
use Interop\Queue\PriorityNotSupportedException;
12-
use Interop\Queue\PsrDestination;
13-
use Interop\Queue\PsrMessage;
14-
use Interop\Queue\PsrProducer;
15-
use Interop\Queue\TimeToLiveNotSupportedException;
16-
17-
class GpsProducer implements PsrProducer
8+
use Interop\Queue\Destination;
9+
use Interop\Queue\Exception\DeliveryDelayNotSupportedException;
10+
use Interop\Queue\Exception\InvalidDestinationException;
11+
use Interop\Queue\Exception\InvalidMessageException;
12+
use Interop\Queue\Exception\PriorityNotSupportedException;
13+
use Interop\Queue\Exception\TimeToLiveNotSupportedException;
14+
use Interop\Queue\Message;
15+
use Interop\Queue\Producer;
16+
17+
class GpsProducer implements Producer
1818
{
1919
/**
2020
* @var GpsContext
@@ -30,7 +30,7 @@ public function __construct(GpsContext $context)
3030
* @param GpsTopic $destination
3131
* @param GpsMessage $message
3232
*/
33-
public function send(PsrDestination $destination, PsrMessage $message): void
33+
public function send(Destination $destination, Message $message): void
3434
{
3535
InvalidDestinationException::assertDestinationInstanceOf($destination, GpsTopic::class);
3636
InvalidMessageException::assertMessageInstanceOf($message, GpsMessage::class);
@@ -42,7 +42,7 @@ public function send(PsrDestination $destination, PsrMessage $message): void
4242
]);
4343
}
4444

45-
public function setDeliveryDelay(int $deliveryDelay = null): PsrProducer
45+
public function setDeliveryDelay(int $deliveryDelay = null): Producer
4646
{
4747
if (null === $deliveryDelay) {
4848
return $this;
@@ -56,7 +56,7 @@ public function getDeliveryDelay(): ?int
5656
return null;
5757
}
5858

59-
public function setPriority(int $priority = null): PsrProducer
59+
public function setPriority(int $priority = null): Producer
6060
{
6161
if (null === $priority) {
6262
return $this;
@@ -70,7 +70,7 @@ public function getPriority(): ?int
7070
return null;
7171
}
7272

73-
public function setTimeToLive(int $timeToLive = null): PsrProducer
73+
public function setTimeToLive(int $timeToLive = null): Producer
7474
{
7575
if (null === $timeToLive) {
7676
return $this;

pkg/gps/GpsQueue.php

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

55
namespace Enqueue\Gps;
66

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

9-
class GpsQueue implements PsrQueue
9+
class GpsQueue implements Queue
1010
{
1111
/**
1212
* @var string

pkg/gps/GpsTopic.php

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

55
namespace Enqueue\Gps;
66

7-
use Interop\Queue\PsrTopic;
7+
use Interop\Queue\Topic;
88

9-
class GpsTopic implements PsrTopic
9+
class GpsTopic implements Topic
1010
{
1111
/**
1212
* @var string

pkg/gps/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/gps/d/total.png)](https://packagist.org/packages/enqueue/gps)
66
[![Latest Stable Version](https://poser.pugx.org/enqueue/gps/version.png)](https://packagist.org/packages/enqueue/gps)
77

8-
This is an implementation of PSR specification. It allows you to send and consume message through Google Pub/Sub library.
8+
This is an implementation of Queue Interop specification. It allows you to send and consume message through Google Pub/Sub library.
99

1010
## Resources
1111

pkg/gps/Tests/GpsContextTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Enqueue\Gps\GpsTopic;
88
use Google\Cloud\Core\Exception\ConflictException;
99
use Google\Cloud\PubSub\PubSubClient;
10-
use Interop\Queue\InvalidDestinationException;
10+
use Interop\Queue\Exception\InvalidDestinationException;
1111
use PHPUnit\Framework\TestCase;
1212

1313
class GpsContextTest extends TestCase

pkg/gps/Tests/GpsProducerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Enqueue\Gps\GpsTopic;
1010
use Google\Cloud\PubSub\PubSubClient;
1111
use Google\Cloud\PubSub\Topic;
12-
use Interop\Queue\InvalidDestinationException;
12+
use Interop\Queue\Exception\InvalidDestinationException;
1313
use PHPUnit\Framework\TestCase;
1414

1515
class GpsProducerTest extends TestCase

pkg/gps/Tests/Spec/GpsSendToTopicAndReceiveFromQueueTest.php

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

55
use Enqueue\Gps\GpsContext;
66
use Enqueue\Test\GpsExtension;
7-
use Interop\Queue\PsrContext;
7+
use Interop\Queue\Context;
88
use Interop\Queue\Spec\SendToTopicAndReceiveNoWaitFromQueueSpec;
99

1010
/**
@@ -25,7 +25,7 @@ protected function createContext()
2525
* @param GpsContext $context
2626
* @param mixed $queueName
2727
*/
28-
protected function createQueue(PsrContext $context, $queueName)
28+
protected function createQueue(Context $context, $queueName)
2929
{
3030
$queue = parent::createQueue($context, $queueName);
3131

@@ -34,7 +34,7 @@ protected function createQueue(PsrContext $context, $queueName)
3434
return $queue;
3535
}
3636

37-
protected function createTopic(PsrContext $context, $topicName)
37+
protected function createTopic(Context $context, $topicName)
3838
{
3939
return $this->topic = parent::createTopic($context, $topicName);
4040
}

0 commit comments

Comments
 (0)