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

fix: Allow overriding the publisher in PartitionCountWatchingPublisherSettings #1342

Merged
merged 2 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ If you are using Maven, add this to your pom.xml file:
If you are using Gradle without BOM, add this to your dependencies:

```Groovy
implementation 'com.google.cloud:google-cloud-pubsublite:1.10.0'
implementation 'com.google.cloud:google-cloud-pubsublite:1.11.0'
```

If you are using SBT, add this to your dependencies:

```Scala
libraryDependencies += "com.google.cloud" % "google-cloud-pubsublite" % "1.10.0"
libraryDependencies += "com.google.cloud" % "google-cloud-pubsublite" % "1.11.0"
```

## Authentication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.cloud.pubsublite.internal.AlarmFactory;
import com.google.cloud.pubsublite.internal.DefaultRoutingPolicy;
import com.google.cloud.pubsublite.internal.Publisher;
import com.google.cloud.pubsublite.internal.RoutingPolicy;
import java.time.Duration;

@AutoValue
Expand All @@ -37,9 +38,12 @@ public abstract class PartitionCountWatchingPublisherSettings {
// Optional parameters
abstract Duration configPollPeriod();

abstract RoutingPolicy.Factory routingPolicyFactory();

public static Builder newBuilder() {
return new AutoValue_PartitionCountWatchingPublisherSettings.Builder()
.setConfigPollPeriod(Duration.ofMinutes(1));
.setConfigPollPeriod(Duration.ofMinutes(1))
.setRoutingPolicyFactory(DefaultRoutingPolicy::new);
}

@AutoValue.Builder
Expand All @@ -54,13 +58,15 @@ public abstract static class Builder {
// Optional parameters.
public abstract Builder setConfigPollPeriod(Duration period);

public abstract Builder setRoutingPolicyFactory(RoutingPolicy.Factory factory);

public abstract PartitionCountWatchingPublisherSettings build();
}

public Publisher<MessageMetadata> instantiate() throws ApiException {
return new PartitionCountWatchingPublisher(
publisherFactory(),
DefaultRoutingPolicy::new,
routingPolicyFactory(),
new PartitionCountWatcherImpl.Factory(
topic(), adminClient(), AlarmFactory.create(configPollPeriod())));
}
Expand Down