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

Commit 51c87d5

Browse files
fix grpc timeouts
1 parent 5aad8c4 commit 51c87d5

File tree

5 files changed

+37
-6
lines changed

5 files changed

+37
-6
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ RUN curl -o /tmp/composer-setup.php https://getcomposer.org/installer \
2929
# Install Composer Application Dependencies
3030
COPY composer.json /opt/php-pubsub/
3131
RUN composer install --no-autoloader --no-scripts --no-interaction \
32-
&& composer require google/proto-client-php ^0.6 \
32+
&& composer require google/proto-client-php ^0.10.0 \
3333
&& composer require google/gax
3434

3535
COPY src /opt/php-pubsub/src

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The library will automatically choose gRPC over REST if all dependencies are ins
3131
pecl install grpc
3232

3333
composer require google/gax
34-
composer require google/proto-client-php ^0.6
34+
composer require google/proto-client-php ^0.10.0
3535
```
3636

3737
## Usage

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 3.0.1 - ?
4+
5+
* Fix to gRPC timeouts
6+
37
## 3.0.0 - 2017-01-03
48

59
* Bump up google/cloud requirement to ^0.11.0|^0.12.0|^0.13.0|^0.20.0

src/GoogleCloudPubSubAdapter.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ public function subscribe($channel, callable $handler)
136136
$isSubscriptionLoopActive = true;
137137

138138
while ($isSubscriptionLoopActive) {
139-
$messages = $subscription->pull();
139+
$messages = $subscription->pull([
140+
'grpcOptions' => [
141+
'timeoutMillis' => null,
142+
],
143+
]);
140144

141145
foreach ($messages as $message) {
142146
/** @var Message $message */

tests/GoogleCloudPubSubAdapterTest.php

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,19 @@ public function testSubscribeWhenSubscriptionMustBeCreated()
140140
->andReturn(false);
141141
$subscription->shouldReceive('create')
142142
->once();
143-
$subscription->shouldReceive('pull')
144-
->once()
145-
->andReturn($messageBatch1);
143+
146144
$subscription->shouldReceive('acknowledge')
147145
->with($message1)
148146
->once();
149147
$subscription->shouldReceive('acknowledge')
150148
->with($message2)
151149
->once();
152150
$subscription->shouldReceive('pull')
151+
->with([
152+
'grpcOptions' => [
153+
'timeoutMillis' => null,
154+
],
155+
])
153156
->once()
154157
->andReturn($messageBatch2);
155158
$subscription->shouldReceive('acknowledge')
@@ -205,6 +208,11 @@ public function testSubscribeWhenSubscriptionExists()
205208
->andReturn(true);
206209
$subscription->shouldNotHaveReceived('create');
207210
$subscription->shouldReceive('pull')
211+
->with([
212+
'grpcOptions' => [
213+
'timeoutMillis' => null,
214+
],
215+
])
208216
->once()
209217
->andReturn($messageBatch1);
210218
$subscription->shouldReceive('acknowledge')
@@ -214,6 +222,11 @@ public function testSubscribeWhenSubscriptionExists()
214222
->with($message2)
215223
->once();
216224
$subscription->shouldReceive('pull')
225+
->with([
226+
'grpcOptions' => [
227+
'timeoutMillis' => null,
228+
],
229+
])
217230
->once()
218231
->andReturn($messageBatch2);
219232
$subscription->shouldReceive('acknowledge')
@@ -267,6 +280,11 @@ public function testSubscribeWhenAutoTopicCreationIsDisabled()
267280
$subscription->shouldNotHaveReceived('exists');
268281
$subscription->shouldNotHaveReceived('create');
269282
$subscription->shouldReceive('pull')
283+
->with([
284+
'grpcOptions' => [
285+
'timeoutMillis' => null,
286+
],
287+
])
270288
->once()
271289
->andReturn($messageBatch1);
272290
$subscription->shouldReceive('acknowledge')
@@ -276,6 +294,11 @@ public function testSubscribeWhenAutoTopicCreationIsDisabled()
276294
->with($message2)
277295
->once();
278296
$subscription->shouldReceive('pull')
297+
->with([
298+
'grpcOptions' => [
299+
'timeoutMillis' => null,
300+
],
301+
])
279302
->once()
280303
->andReturn($messageBatch2);
281304
$subscription->shouldReceive('acknowledge')

0 commit comments

Comments
 (0)