Skip to content

Commit

Permalink
Created new grpc wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
surbhigarg92 committed Nov 15, 2024
1 parent 6b0b400 commit 387fad5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
import com.google.cloud.spanner.admin.instance.v1.stub.InstanceAdminStub;
import com.google.cloud.spanner.admin.instance.v1.stub.InstanceAdminStubSettings;
import com.google.cloud.spanner.encryption.EncryptionConfigProtoMapper;
import com.google.cloud.spanner.v1.stub.GrpcSpannerStub;
import com.google.cloud.spanner.v1.stub.GrpcSpannerStubWrapper;
import com.google.cloud.spanner.v1.stub.SpannerStub;
import com.google.cloud.spanner.v1.stub.SpannerStubSettings;
import com.google.common.annotations.VisibleForTesting;
Expand Down Expand Up @@ -410,7 +410,7 @@ public GapicSpannerRpc(final SpannerOptions options) {
/* isAdminClient = */ false, isEmulatorEnabled(options, emulatorHost)))
.build();
ClientContext clientContext = ClientContext.create(spannerStubSettings);
this.spannerStub = GrpcSpannerStub.create(spannerStubSettings, clientContext);
this.spannerStub = GrpcSpannerStubWrapper.create(spannerStubSettings, clientContext);
BuiltInMetricsConstant.DIRECT_PATH_ENABLED =
((GrpcTransportChannel) clientContext.getTransportChannel()).isDirectPath()
&& isAttemptDirectPathXds;
Expand Down Expand Up @@ -461,7 +461,7 @@ public GapicSpannerRpc(final SpannerOptions options) {
.getStreamWatchdogProvider()
.withCheckInterval(pdmlSettings.getStreamWatchdogCheckInterval()));
}
this.partitionedDmlStub = GrpcSpannerStub.create(pdmlSettings.build());
this.partitionedDmlStub = GrpcSpannerStubWrapper.create(pdmlSettings.build());
this.instanceAdminStubSettings =
options
.getInstanceAdminStubSettings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,6 @@ public static final GrpcSpannerStub create(ClientContext clientContext) throws I
return new GrpcSpannerStub(SpannerStubSettings.newBuilder().build(), clientContext);
}

public static final GrpcSpannerStub create(
SpannerStubSettings settings, ClientContext clientContext) throws IOException {
return new GrpcSpannerStub(settings, clientContext);
}

public static final GrpcSpannerStub create(
ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
return new GrpcSpannerStub(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2024 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.spanner.v1.stub;

import com.google.api.gax.rpc.ClientContext;
import java.io.IOException;

public class GrpcSpannerStubWrapper extends GrpcSpannerStub {

public static final GrpcSpannerStubWrapper create(
SpannerStubSettings settings, ClientContext clientContext) throws IOException {
return new GrpcSpannerStubWrapper(settings, clientContext);
}

protected GrpcSpannerStubWrapper(SpannerStubSettings settings, ClientContext clientContext)
throws IOException {
super(settings, clientContext);
}
}

0 comments on commit 387fad5

Please sign in to comment.