Skip to content
This repository was archived by the owner on Jul 19, 2024. It is now read-only.

Commit d5376d1

Browse files
bump up google/cloud requirement to ^0.11.0 and fix breaking changes implemented in lib
1 parent 22aad5f commit d5376d1

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"require": {
1212
"php": ">=5.6.0",
1313
"superbalist/php-pubsub": "^1.0",
14-
"google/cloud": "^0.7.0|^0.8.0|^0.9.0|^0.10.0"
14+
"google/cloud": "^0.11.0"
1515
},
1616
"autoload": {
1717
"psr-4": {

src/GoogleCloudPubSubAdapter.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Superbalist\PubSub\GoogleCloud;
44

5+
use Google\Cloud\PubSub\Message;
56
use Google\Cloud\PubSub\PubSubClient;
67
use Superbalist\PubSub\PubSubAdapterInterface;
78
use Superbalist\PubSub\Utils;
@@ -34,8 +35,12 @@ class GoogleCloudPubSubAdapter implements PubSubAdapterInterface
3435
* @param bool $autoCreateTopics
3536
* @param bool $autoCreateSubscriptions
3637
*/
37-
public function __construct(PubSubClient $client, $clientIdentifier = null, $autoCreateTopics = true, $autoCreateSubscriptions = true)
38-
{
38+
public function __construct(
39+
PubSubClient $client,
40+
$clientIdentifier = null,
41+
$autoCreateTopics = true,
42+
$autoCreateSubscriptions = true
43+
) {
3944
$this->client = $client;
4045
$this->clientIdentifier = $clientIdentifier;
4146
$this->autoCreateTopics = $autoCreateTopics;
@@ -134,17 +139,17 @@ public function subscribe($channel, callable $handler)
134139
$messages = $subscription->pull();
135140

136141
foreach ($messages as $message) {
137-
// the cloud library base64 encodes messages
138-
$payload = base64_decode($message['message']['data']);
139-
$payload = Utils::unserializeMessagePayload($payload);
142+
/** @var Message $message */
143+
144+
$payload = Utils::unserializeMessagePayload($message->data());
140145

141146
if ($payload === 'unsubscribe') {
142147
$isSubscriptionLoopActive = false;
143148
} else {
144149
call_user_func($handler, $payload);
145150
}
146151

147-
$subscription->acknowledge($message['ackId']);
152+
$subscription->acknowledge($message);
148153
}
149154
}
150155
}

0 commit comments

Comments
 (0)