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 CredentialsProvider to Publisher and Subscriber settings #475
Conversation
These objects require more than one client and are annoying to construct correctly. Add a commonly needed setting to the top level here. Fixes #472
Codecov Report
@@ Coverage Diff @@
## master #475 +/- ##
============================================
- Coverage 73.09% 72.67% -0.43%
- Complexity 835 840 +5
============================================
Files 151 151
Lines 4368 4374 +6
Branches 222 214 -8
============================================
- Hits 3193 3179 -14
- Misses 1056 1078 +22
+ Partials 119 117 -2 Continue to review full report at Codecov.
|
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.
LGTM if my comment is addressed.
@@ -1,15 +1,11 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!-- see http://www.mojohaus.org/clirr-maven-plugin/examples/ignored-differences.html --> | |||
<differences> | |||
<!-- Removed not needed API --> | |||
<!-- Added abstract method to AutoValue.Builder class (Always okay) --> |
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.
Can you instead add a specific exclusion for what you are adding? Not all changes to Builders will be adding abstract methods. Will this trigger on removing methods?
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 specifically triggers on adding methods to nested classes named "Builder". I think thats specific enough. (code 7013 is added abstract method to abstract class)
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, this isn't specific enough and would require a major version bump if this API had reached 1.0.
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 disagree. Addition of a method to a Builder class, which is only overridden in an autogenerated AutoValue file, would not trigger a major version bump as it is not a backwards-incompatible API surface change.
@@ -1,15 +1,11 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<!-- see http://www.mojohaus.org/clirr-maven-plugin/examples/ignored-differences.html --> | |||
<differences> | |||
<!-- Removed not needed API --> | |||
<!-- Added abstract method to AutoValue.Builder class (Always okay) --> |
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, this isn't specific enough and would require a major version bump if this API had reached 1.0.
Irrelevant to present library state. Possibly would be worth an out of band discussion, but dismissing to unblock a customer issue.
@dpcollins-google I'm thinking to upgrade google-cloud-pubsublite dependency in Apache Beam (Google Dataflow) from 0.7.0 to 0.13.2. It has breaking changes including this PR475 (compilation errors). Before I try to fix Beam's code, do you happen to know anyone working on Beam's pubsublite dependency upgrade already? |
Committer wireCommitter = | ||
CommitterSettings.newBuilder() | ||
.setSubscriptionPath(subscriptionPath()) | ||
.setPartition(partition) | ||
.setServiceClient(newCursorServiceClient()) | ||
.build() | ||
.instantiate(); |
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.
Memo for myself. This seems the way to replace CommitterBuilder:
CommitterBuilder.Builder wireCommitterBuilder = CommitterBuilder.newBuilder();
wireCommitterBuilder.setSubscriptionPath(canonicalPath);
cursorServiceClientSupplier()
.ifPresent(supplier -> wireCommitterBuilder.setServiceClient(supplier.get()));
wireCommitterBuilder.setPartition(partition);
@@ -125,16 +188,12 @@ Publisher instantiate() throws ApiException { | |||
SinglePartitionPublisherBuilder.Builder singlePartitionBuilder = | |||
underlyingBuilder() | |||
.setBatchingSettings(batchingSettings) | |||
.setContext(PubsubContext.of(FRAMEWORK)) |
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.
Beam also touches this removed setContext method. Should it just remove the usage?
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 has been moved to newServiceClient method. (Thanks @dpcollins-google !)
public PartitionCountWatchingPublisher(PartitionCountWatchingPublisherSettings settings) { | ||
this.publisherFactory = settings.publisherFactory(); | ||
this.policyFactory = settings.routingPolicyFactory(); | ||
PartitionCountWatcher configWatcher = | ||
settings.configWatcherFactory().newWatcher(this::handleConfig); | ||
PartitionCountWatchingPublisher( | ||
PartitionPublisherFactory publisherFactory, | ||
RoutingPolicy.Factory policyFactory, | ||
PartitionCountWatcher.Factory configWatcherFactory) { | ||
this.publisherFactory = publisherFactory; | ||
this.policyFactory = policyFactory; | ||
PartitionCountWatcher configWatcher = configWatcherFactory.newWatcher(this::handleConfig); | ||
addServices(configWatcher); | ||
} |
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.
Memo for myself. This constructor is now invisible but used by Beam
https://github.com/apache/beam/blob/243128a8fc52798e1b58b0cf1a271d95ee7aa241/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/pubsublite/Publishers.java#L46
PublisherServiceSettings.Builder settingsBuilder = PublisherServiceSettings.newBuilder(); | ||
settingsBuilder = | ||
addDefaultMetadata( | ||
PubsubContext.of(FRAMEWORK), |
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.
Note for myself. This sets the context now.
These objects require more than one client and are annoying to construct correctly. Add a commonly needed setting to the top level here.
Fixes #472