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

feat: introduce java.time variables and methods #1784

Merged
merged 1 commit into from
Nov 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
package com.google.cloud.pubsublite;

import com.google.api.gax.retrying.RetrySettings;
import org.threeten.bp.Duration;
import java.time.Duration;

/** Useful general constants for Pub/Sub Lite. */
public class Constants {
public static final RetrySettings DEFAULT_RETRY_SETTINGS =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(100))
.setInitialRetryDelayDuration(Duration.ofMillis(100))
.setRetryDelayMultiplier(1.3)
.setMaxRetryDelay(Duration.ofSeconds(60))
.setMaxRetryDelayDuration(Duration.ofSeconds(60))
.setJittered(true)
.setTotalTimeout(Duration.ofMinutes(10))
.setTotalTimeoutDuration(Duration.ofMinutes(10))
.build();

public static final long MAX_PUBLISH_BATCH_COUNT = 1_000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
import com.google.protobuf.ByteString;
import com.google.pubsub.v1.PubsubMessage;
import io.grpc.CallOptions;
import java.time.Duration;
import java.util.Optional;
import org.threeten.bp.Duration;

/**
* Settings for instantiating a Pub/Sub Lite publisher emulating the Cloud Pub/Sub Publisher API.
Expand All @@ -64,7 +64,7 @@ public abstract class PublisherSettings {
.setIsEnabled(true)
.setElementCountThreshold(1000L)
.setRequestByteThreshold(Constants.MAX_PUBLISH_BATCH_BYTES)
.setDelayThreshold(Duration.ofMillis(50))
.setDelayThresholdDuration(Duration.ofMillis(50))
.build();

// Required parameters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import com.google.cloud.pubsublite.internal.Lazy;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Multimaps;
import java.time.Duration;
import java.util.concurrent.ScheduledExecutorService;
import org.threeten.bp.Duration;

public final class ServiceClients {
private static final Lazy<ScheduledExecutorService> GRPC_EXECUTOR =
Expand All @@ -42,9 +42,9 @@ private ServiceClients() {}
private static TransportChannelProvider getTransportChannelProvider() {
return InstantiatingGrpcChannelProvider.newBuilder()
.setMaxInboundMessageSize(Integer.MAX_VALUE)
.setKeepAliveTime(Duration.ofMinutes(1))
.setKeepAliveTimeDuration(Duration.ofMinutes(1))
.setKeepAliveWithoutCalls(true)
.setKeepAliveTimeout(Duration.ofMinutes(1))
.setKeepAliveTimeoutDuration(Duration.ofMinutes(1))
.setChannelPoolSettings(
ChannelPoolSettings.builder()
.setInitialChannelCount(25)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.protobuf.ByteString;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand All @@ -75,7 +76,6 @@
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.stubbing.Answer;
import org.threeten.bp.Duration;

@RunWith(JUnit4.class)
public class PublisherImplTest {
Expand All @@ -86,7 +86,7 @@ public class PublisherImplTest {
private static final BatchingSettings BATCHING_SETTINGS_THAT_NEVER_FIRE =
BatchingSettings.newBuilder()
.setIsEnabled(true)
.setDelayThreshold(Duration.ofDays(10))
.setDelayThresholdDuration(Duration.ofDays(10))
.setRequestByteThreshold(1000000L)
.setElementCountThreshold(1000000L)
.build();
Expand Down
Loading