-
Notifications
You must be signed in to change notification settings - Fork 430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for dead letter policies #2504
Conversation
cc @pradn |
PubSub/src/Message.php
Outdated
@@ -70,6 +75,10 @@ class Message | |||
* | |||
* @type string $ackId The message ackId. This is only set when messages | |||
* are pulled from the PubSub service. | |||
* @type string $deliveryAttempt Delivery attempt counter is 1 + (the | |||
* sum of number of NACKs and number of ack_deadline exceeds) for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: extra space.
{ | ||
if ($client instanceof PubSubClientRest) { | ||
$this->markTestSkipped( | ||
'deadLetterPolicy not available in REST transport during experimental period.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is when DLQ is alpha?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure when the new feature will be published to the REST definition. We've had the same issue with ordering keys.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has this been actually resolved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest version of the discovery document does not include dead letter queues: https://pubsub.googleapis.com/$discovery/rest?version=v1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we notate this in the client?
Okay, did an initial review. Just small things. Looks good, overall. |
@dwsupplee Can you help review this? Thanks! |
PubSub/src/Message.php
Outdated
@@ -70,6 +75,10 @@ class Message | |||
* | |||
* @type string $ackId The message ackId. This is only set when messages | |||
* are pulled from the PubSub service. | |||
* @type string $deliveryAttempt Delivery attempt counter is 1 + (the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int?
if (isset($subscription['deadLetterPolicy'])) { | ||
if ($subscription['deadLetterPolicy']['deadLetterTopic'] instanceof Topic) { | ||
$topic = $subscription['deadLetterPolicy']['deadLetterTopic']; | ||
$subscription['deadLetterPolicy']['deadLetterTopic'] = $topic->name(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about maximum delivery attempts field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No transformation is required to make the max delivery attempts field compatible with the API.
{ | ||
if ($client instanceof PubSubClientRest) { | ||
$this->markTestSkipped( | ||
'deadLetterPolicy not available in REST transport during experimental period.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has this been actually resolved?
* will fail if the topic does not exist. Users should ensure that | ||
* there is a subscription attached to this topic since messages | ||
* published to a topic with no subscriptions are lost. | ||
* @type int $deadLetterPolicy.maxDeliveryAttempts The maximum number of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see maxDeliveryAttempts field being used in any tests. We should write some tests with custom maxDeliveryAttempts and some with default maxDeliveryAttempts (5).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added system test coverage.
PubSub/tests/Unit/MessageTest.php
Outdated
@@ -87,6 +88,11 @@ public function testAckId() | |||
$this->assertEquals(1234, $this->message->ackId()); | |||
} | |||
|
|||
public function testDeliveryAttempt() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a unit test for null delivery attempt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure thing! done.
{ | ||
if ($client instanceof PubSubClientRest) { | ||
$this->markTestSkipped( | ||
'deadLetterPolicy not available in REST transport during experimental period.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we notate this in the client?
I refactored the Grpc.php unit test file, the provider is too difficult to manage.
Closes #2571.