Skip to content

Commit

Permalink
fix: create a hard failure when batching settings with flow control a…
Browse files Browse the repository at this point in the history
…re used (#758)

* fix: create a hard failure when invalid batching settings are set

* fix: reformat
  • Loading branch information
dpcollins-google committed Jul 26, 2021
1 parent 6f64152 commit 459378d
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.api.gax.batching.BatchingSettings;
import com.google.api.gax.core.CredentialsProvider;
import com.google.api.gax.rpc.ApiException;
import com.google.api.gax.rpc.StatusCode.Code;
import com.google.auto.value.AutoValue;
import com.google.cloud.pubsublite.AdminClient;
import com.google.cloud.pubsublite.AdminClientSettings;
Expand All @@ -32,6 +33,7 @@
import com.google.cloud.pubsublite.Partition;
import com.google.cloud.pubsublite.TopicPath;
import com.google.cloud.pubsublite.cloudpubsub.internal.WrappingPublisher;
import com.google.cloud.pubsublite.internal.CheckedApiException;
import com.google.cloud.pubsublite.internal.wire.PartitionCountWatchingPublisherSettings;
import com.google.cloud.pubsublite.internal.wire.PubsubContext;
import com.google.cloud.pubsublite.internal.wire.PubsubContext.Framework;
Expand Down Expand Up @@ -185,6 +187,13 @@ private AdminClient getAdminClient() throws ApiException {
@SuppressWarnings("CheckReturnValue")
Publisher instantiate() throws ApiException {
BatchingSettings batchingSettings = batchingSettings().orElse(DEFAULT_BATCHING_SETTINGS);
if (batchingSettings.getFlowControlSettings().getMaxOutstandingElementCount() != null
|| batchingSettings.getFlowControlSettings().getMaxOutstandingRequestBytes() != null) {
throw new CheckedApiException(
"Pub/Sub Lite does not support flow control settings for publishing.",
Code.INVALID_ARGUMENT)
.underlying;
}
KeyExtractor keyExtractor = keyExtractor().orElse(KeyExtractor.DEFAULT);
MessageTransformer<PubsubMessage, Message> messageTransformer =
messageTransformer()
Expand Down

0 comments on commit 459378d

Please sign in to comment.