diff --git a/README.md b/README.md index 5e43686c1..91df02ed2 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ If you are using Maven without the BOM, add this to your dependencies: If you are using Gradle 5.x or later, add this to your dependencies: ```Groovy -implementation platform('com.google.cloud:libraries-bom:26.69.0') +implementation platform('com.google.cloud:libraries-bom:26.70.0') implementation 'com.google.cloud:google-cloud-pubsub' ``` diff --git a/generation_config.yaml b/generation_config.yaml index b70e279e6..9d0d56a4a 100644 --- a/generation_config.yaml +++ b/generation_config.yaml @@ -1,6 +1,6 @@ gapic_generator_version: 2.62.3 -googleapis_commitish: 6e79e73204aed17b11e724beebb9cf11f36ea57d -libraries_bom_version: 26.69.0 +googleapis_commitish: db61975fe3b3edabed32fda8056d08e79a93a59e +libraries_bom_version: 26.70.0 libraries: - api_shortname: pubsub name_pretty: Cloud Pub/Sub diff --git a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriberShutdownSettings.java b/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriberShutdownSettings.java deleted file mode 100644 index efd8e10db..000000000 --- a/google-cloud-pubsub/src/main/java/com/google/cloud/pubsub/v1/SubscriberShutdownSettings.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2025 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.cloud.pubsub.v1; - -import com.google.common.base.Preconditions; -import java.time.Duration; - -/** - * Settings for configuring the shutdown behavior of a {@link Subscriber}. - * - *
This class allows customization of how the subscriber handles outstanding messages during - * shutdown, including whether to wait for processing to complete or to immediately nack messages, - * and an optional timeout for the shutdown process. - */ -public final class SubscriberShutdownSettings { - - /** Defines the behavior for handling outstanding messages during subscriber shutdown. */ - public enum ShutdownMode { - /** - * The subscriber will wait for all outstanding messages to be processed (acked or nacked by the - * user's message receiver) before completing the shutdown. - */ - WAIT_FOR_PROCESSING, - /** - * The subscriber will immediately nack all outstanding messages and attempt to shut down as - * quickly as possible. Messages delivered to the user callback but not yet acked/nacked will - * also be nacked. - */ - NACK_IMMEDIATELY - } - - private static final Duration DEFAULT_TIMEOUT = Duration.ofSeconds(-1); // Indicates no timeout - private static final ShutdownMode DEFAULT_MODE = ShutdownMode.WAIT_FOR_PROCESSING; - - private final ShutdownMode mode; - private final Duration timeout; - - private SubscriberShutdownSettings(Builder builder) { - this.mode = builder.mode; - this.timeout = builder.timeout; - } - - /** Returns the configured shutdown mode. */ - public ShutdownMode getMode() { - return mode; - } - - /** Returns the configured shutdown timeout. A negative duration indicates no timeout. */ - public Duration getTimeout() { - return timeout; - } - - /** Returns a new builder for {@code SubscriberShutdownSettings}. */ - public static Builder newBuilder() { - return new Builder(); - } - - /** Builder for {@code SubscriberShutdownSettings}. */ - public static final class Builder { - private ShutdownMode mode = DEFAULT_MODE; - private Duration timeout = DEFAULT_TIMEOUT; - - private Builder() {} - - /** Sets the shutdown mode. Defaults to {@link ShutdownMode#WAIT_FOR_PROCESSING}. */ - public Builder setMode(ShutdownMode mode) { - this.mode = Preconditions.checkNotNull(mode); - return this; - } - - /** - * Sets the shutdown timeout. Defaults to a negative duration, indicating no timeout. - * - *
A positive duration specifies the maximum time to wait for shutdown to complete. A - * duration of zero indicates an immediate, forceful shutdown. A negative duration indicates an - * indefinite wait. - */ - public Builder setTimeout(Duration timeout) { - this.timeout = Preconditions.checkNotNull(timeout); - return this; - } - - /** Builds an instance of {@code SubscriberShutdownSettings}. */ - public SubscriberShutdownSettings build() { - return new SubscriberShutdownSettings(this); - } - } -} diff --git a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/SubscriberShutdownSettingsTest.java b/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/SubscriberShutdownSettingsTest.java deleted file mode 100644 index f82937582..000000000 --- a/google-cloud-pubsub/src/test/java/com/google/cloud/pubsub/v1/SubscriberShutdownSettingsTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2025 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.cloud.pubsub.v1; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import com.google.cloud.pubsub.v1.SubscriberShutdownSettings.ShutdownMode; -import java.time.Duration; -import org.junit.Test; - -public class SubscriberShutdownSettingsTest { - - @Test - public void testDefaultSettings() { - SubscriberShutdownSettings settings = SubscriberShutdownSettings.newBuilder().build(); - - assertNotNull(settings); - assertEquals(ShutdownMode.WAIT_FOR_PROCESSING, settings.getMode()); - assertTrue(settings.getTimeout().isNegative()); // Indefinite timeout - } - - @Test - public void testWaitForProcessingWithCustomTimeout() { - Duration customTimeout = Duration.ofSeconds(30); - SubscriberShutdownSettings settings = - SubscriberShutdownSettings.newBuilder() - .setMode(ShutdownMode.WAIT_FOR_PROCESSING) - .setTimeout(customTimeout) - .build(); - - assertNotNull(settings); - assertEquals(ShutdownMode.WAIT_FOR_PROCESSING, settings.getMode()); - assertEquals(customTimeout, settings.getTimeout()); - } - - @Test - public void testNackImmediatelyWithDefaultTimeout() { - SubscriberShutdownSettings settings = - SubscriberShutdownSettings.newBuilder().setMode(ShutdownMode.NACK_IMMEDIATELY).build(); - - assertNotNull(settings); - assertEquals(ShutdownMode.NACK_IMMEDIATELY, settings.getMode()); - assertTrue(settings.getTimeout().isNegative()); // Indefinite timeout - } - - @Test - public void testNackImmediatelyWithCustomTimeout() { - Duration customTimeout = Duration.ofSeconds(10); - SubscriberShutdownSettings settings = - SubscriberShutdownSettings.newBuilder() - .setMode(ShutdownMode.NACK_IMMEDIATELY) - .setTimeout(customTimeout) - .build(); - - assertNotNull(settings); - assertEquals(ShutdownMode.NACK_IMMEDIATELY, settings.getMode()); - assertEquals(customTimeout, settings.getTimeout()); - } - - @Test - public void testZeroTimeout() { - Duration zeroTimeout = Duration.ZERO; - SubscriberShutdownSettings settings = - SubscriberShutdownSettings.newBuilder() - .setMode(ShutdownMode.WAIT_FOR_PROCESSING) - .setTimeout(zeroTimeout) - .build(); - - assertNotNull(settings); - assertEquals(ShutdownMode.WAIT_FOR_PROCESSING, settings.getMode()); - assertEquals(zeroTimeout, settings.getTimeout()); - assertTrue(settings.getTimeout().isZero()); - } - - @Test(expected = NullPointerException.class) - public void testNullModeThrowsException() { - SubscriberShutdownSettings.newBuilder().setMode(null).build(); - } - - @Test(expected = NullPointerException.class) - public void testNullTimeoutThrowsException() { - SubscriberShutdownSettings.newBuilder().setTimeout(null).build(); - } -}