-
Notifications
You must be signed in to change notification settings - Fork 136
feat: make grpc-gcp default enabled #4239
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,7 +151,6 @@ public class SpannerOptions extends ServiceOptions<Spanner, SpannerOptions> { | |
| private final InstanceAdminStubSettings instanceAdminStubSettings; | ||
| private final DatabaseAdminStubSettings databaseAdminStubSettings; | ||
| private final Duration partitionedDmlTimeout; | ||
| private final boolean grpcGcpExtensionEnabled; | ||
| private final GcpManagedChannelOptions grpcGcpOptions; | ||
| private final boolean autoThrottleAdministrativeRequests; | ||
| private final RetrySettings retryAdministrativeRequestsSettings; | ||
|
|
@@ -798,7 +797,6 @@ protected SpannerOptions(Builder builder) { | |
| throw SpannerExceptionFactory.newSpannerException(e); | ||
| } | ||
| partitionedDmlTimeout = builder.partitionedDmlTimeout; | ||
| grpcGcpExtensionEnabled = builder.grpcGcpExtensionEnabled; | ||
| grpcGcpOptions = builder.grpcGcpOptions; | ||
| autoThrottleAdministrativeRequests = builder.autoThrottleAdministrativeRequests; | ||
| retryAdministrativeRequestsSettings = builder.retryAdministrativeRequestsSettings; | ||
|
|
@@ -1025,7 +1023,6 @@ public static class Builder | |
| private DatabaseAdminStubSettings.Builder databaseAdminStubSettingsBuilder = | ||
| DatabaseAdminStubSettings.newBuilder(); | ||
| private Duration partitionedDmlTimeout = Duration.ofHours(2L); | ||
| private boolean grpcGcpExtensionEnabled = false; | ||
| private GcpManagedChannelOptions grpcGcpOptions; | ||
| private RetrySettings retryAdministrativeRequestsSettings = | ||
| DEFAULT_ADMIN_REQUESTS_LIMIT_EXCEEDED_RETRY_SETTINGS; | ||
|
|
@@ -1097,7 +1094,6 @@ protected Builder() { | |
| this.instanceAdminStubSettingsBuilder = options.instanceAdminStubSettings.toBuilder(); | ||
| this.databaseAdminStubSettingsBuilder = options.databaseAdminStubSettings.toBuilder(); | ||
| this.partitionedDmlTimeout = options.partitionedDmlTimeout; | ||
| this.grpcGcpExtensionEnabled = options.grpcGcpExtensionEnabled; | ||
| this.grpcGcpOptions = options.grpcGcpOptions; | ||
| this.autoThrottleAdministrativeRequests = options.autoThrottleAdministrativeRequests; | ||
| this.retryAdministrativeRequestsSettings = options.retryAdministrativeRequestsSettings; | ||
|
|
@@ -1573,14 +1569,12 @@ public Builder enableGrpcGcpExtension() { | |
| * Multiplexed sessions are not supported for gRPC-GCP. | ||
| */ | ||
| public Builder enableGrpcGcpExtension(GcpManagedChannelOptions options) { | ||
| this.grpcGcpExtensionEnabled = true; | ||
| this.grpcGcpOptions = options; | ||
| return this; | ||
| } | ||
|
|
||
| /** Disables gRPC-GCP extension. */ | ||
| public Builder disableGrpcGcpExtension() { | ||
| this.grpcGcpExtensionEnabled = false; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While removing this line is correct as part of making gRPC-GCP always enabled, the It would be best to modify the method on the right side to be: /**
* Disables gRPC-GCP extension.
*
* @deprecated gRPC-GCP is now enabled by default and can no longer be disabled. This method is a no-op.
*/
@java.lang.Deprecated
public Builder disableGrpcGcpExtension() {
return this;
} |
||
| return this; | ||
| } | ||
|
|
||
|
|
@@ -1793,8 +1787,7 @@ public SpannerOptions build() { | |
| credentials = environment.getDefaultExperimentalHostCredentials(); | ||
| } | ||
| if (this.numChannels == null) { | ||
| this.numChannels = | ||
| this.grpcGcpExtensionEnabled ? GRPC_GCP_ENABLED_DEFAULT_CHANNELS : DEFAULT_CHANNELS; | ||
| this.numChannels = GRPC_GCP_ENABLED_DEFAULT_CHANNELS; | ||
| } | ||
|
|
||
| synchronized (lock) { | ||
|
|
@@ -1989,7 +1982,7 @@ public Duration getPartitionedDmlTimeoutDuration() { | |
| } | ||
|
|
||
| public boolean isGrpcGcpExtensionEnabled() { | ||
| return grpcGcpExtensionEnabled; | ||
| return true; | ||
| } | ||
|
|
||
| public GcpManagedChannelOptions getGrpcGcpOptions() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1100,9 +1100,10 @@ public void testDefaultNumChannelsWithGrpcGcpExtensionDisabled() { | |
| SpannerOptions.newBuilder() | ||
| .setProjectId("test-project") | ||
| .setCredentials(NoCredentials.getInstance()) | ||
| .disableGrpcGcpExtension() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The name of this test, |
||
| .build(); | ||
|
|
||
| assertEquals(SpannerOptions.DEFAULT_CHANNELS, options.getNumChannels()); | ||
| assertEquals(SpannerOptions.GRPC_GCP_ENABLED_DEFAULT_CHANNELS, options.getNumChannels()); | ||
| } | ||
|
|
||
| @Test | ||
|
|
@@ -1135,9 +1136,10 @@ public void testNumChannelsWithGrpcGcpExtensionEnabled() { | |
|
|
||
| @Test | ||
| public void checkCreatedInstanceWhenGrpcGcpExtensionDisabled() { | ||
| SpannerOptions options = SpannerOptions.newBuilder().setProjectId("test-project").build(); | ||
| SpannerOptions options = | ||
| SpannerOptions.newBuilder().setProjectId("test-project").disableGrpcGcpExtension().build(); | ||
|
Comment on lines
+1139
to
+1140
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The name of this test, |
||
| SpannerOptions options1 = options.toBuilder().build(); | ||
| assertEquals(false, options.isGrpcGcpExtensionEnabled()); | ||
| assertEquals(true, options.isGrpcGcpExtensionEnabled()); | ||
| assertEquals(options.isGrpcGcpExtensionEnabled(), options1.isGrpcGcpExtensionEnabled()); | ||
|
|
||
| Spanner spanner1 = options.getService(); | ||
|
|
||
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 line is correctly removed. However, with gRPC-GCP now enabled by default, the method name
enableGrpcGcpExtensionis misleading as it only configures options. Consider deprecating this method and introducing a new one with a more descriptive name likesetGrpcGcpOptionsto improve API clarity.