Skip to content
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

Support min/max duration per ack extension for pubsub #1254

Merged

Conversation

JoeWang1127
Copy link
Contributor

@JoeWang1127 JoeWang1127 commented Sep 7, 2022

Support minDurationPerAckExtension and maxDurationPerAckExtension for pubsub.

Note that the validation logic is NOT implemented in this PR, because the server will respond an exception if the two parameters are invalid, e.g., either of the parameters is negative or minDurationPerAckExtension is larger than maxDurationPerAckExtension. I add some unit tests to check the server's behavior so that these tests will fail if the sever removed or changed the validation logic in future version.

@elefeint elefeint requested a review from mpeddada1 September 7, 2022 19:59
@JoeWang1127 JoeWang1127 marked this pull request as ready for review September 8, 2022 14:13
@JoeWang1127 JoeWang1127 requested a review from elefeint September 8, 2022 14:13
Copy link
Contributor

@mpeddada1 mpeddada1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really good test coverage! Added the first round of comments:) It might also be worth including these properties in PubSubAutoConfigurationIntegrationTests

docs/src/main/md/pubsub.md Outdated Show resolved Hide resolved
@@ -552,13 +553,61 @@ void subscriberExecutorProvider_globalAndSelectiveConfigurationSet_selectiveTake
});
}

@Test
void pullConfig_defaultConfigurationSet() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we also add assertions for other pull configs? I don't think we have a similar test for checking the default value for those anywhere.

Copy link
Contributor Author

@JoeWang1127 JoeWang1127 Sep 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in later commits.

Great advice, in fact, I found out that the default value for parallelPullCount and pullEndpoint are both null, while in pubsub docs the default value should be 1 and pubsub.googleapis.com:443, respectively. Any reasons about this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid setting defaults for the user, even if they are the same as the client library. There was at least one instance in which the client library changed the default, but Spring Cloud GCP did not, and it led to a hard-to-troubleshoot issue.
Best practice is to allow null in Properties, so that we only modify client library builders if the user explicitly set some option.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at original code, and it looks like we avoid setting our own defaults in parallelPullCount and computeRetryableCodes, but not for computeMaxAckExtensionPeriod, which you naturally used as a reference point. There was probably a reason for it, but see if you can manage to pass nulls back up to PublisherFactory for the new properties -- that would be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean SubscriberFactory because new properties are subscriber settings. To double check, you think we should set the default value of two new properties to null rather than 0?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, yes, SubscriberFactory.
Leaving the value of wrapper types unset will automatically make them null. See if you can avoid providing a default value and allow the null to get returned through the layers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Now the default value for minDurationPerAckExtension and maxDurationPerAckExtension is null.

I left the default value in docs as is (i.e., 0). I'm not sure whether I should also change it to null, since most default values are not what they actually are.

Copy link
Contributor

@mpeddada1 mpeddada1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! One last comment to add, would it also be possible to add some verification for this in:

Copy link
Contributor

@elefeint elefeint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to integration test if it's reasonable to do

@JoeWang1127
Copy link
Contributor Author

Looking good! One last comment to add, would it also be possible to add some verification for this in:

Sorry I missed your comments last week. I modified the integration test to verify the properties.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

92.0% 92.0% Coverage
0.0% 0.0% Duplication

@JoeWang1127 JoeWang1127 merged commit 9e46a5f into main Sep 12, 2022
@JoeWang1127 JoeWang1127 deleted the feature/support-minDurationPerAckExtension-for-pubsub branch September 12, 2022 19:55
kateryna216 added a commit to kateryna216/spring-cloud-gcp that referenced this pull request Oct 20, 2022
…tform#1254)

* add support for `minDurationPerAckExtension` and `maxDurationPerAckExtension`.

* add unit test for `minDurationPerAckExtension` and `maxDurationPerAckExtension` in PubSubConfiguration.

* support `minDurationPerAckExtension` and `maxDurationPerAckExtension` in default subscriber factory

* add unit test for `minDurationPerAckExtension` and `maxDurationPerAckExtension` in DefaultSubscriberFactory

* add unit test for `minDurationPerAckExtension` and `maxDurationPerAckExtension` in GcpPubSubAutoConfiguration

* change description

* change docs for pubsub

* revert code factorization, leave it to another PR

* change method docs

* refactor code after code review

* remove setters for newly added parameters

* change unit tests to set customer settings using pubsub config

* add comments about setting default value on `minDurationPerAckExtension` and `maxDurationPerAckExtension`.

* change new properties' default value to `null`

* modify unit tests relevant to default value of new properties

* test new properties in integration tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement minDurationPerAckExtension from cloud pubsub java client library
3 participants