Skip to content

Commit d2bfda9

Browse files
committed
feat: Improve upon the default gRPC Connection Pool size
1 parent 4a18ad2 commit d2bfda9

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreOptions.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static com.google.cloud.datastore.Validator.validateNamespace;
2020

2121
import com.google.api.core.BetaApi;
22+
import com.google.api.gax.grpc.ChannelPoolSettings;
2223
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
2324
import com.google.api.gax.rpc.TransportChannelProvider;
2425
import com.google.cloud.ServiceDefaults;
@@ -222,7 +223,9 @@ private DatastoreOptions(Builder builder) {
222223
builder.channelProvider != null
223224
? builder.channelProvider
224225
: GrpcTransportOptions.setUpChannelProvider(
225-
DatastoreSettings.defaultGrpcTransportProviderBuilder(), this);
226+
DatastoreSettings.defaultGrpcTransportProviderBuilder().setChannelPoolSettings(
227+
ChannelPoolSettings.builder().setMinChannelCount(1).setInitialChannelCount(4)
228+
.build()), this);
226229
}
227230
}
228231

google-cloud-datastore/src/main/java/com/google/cloud/datastore/spi/v1/GrpcDatastoreRpc.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.google.api.core.InternalApi;
2525
import com.google.api.gax.core.BackgroundResource;
2626
import com.google.api.gax.core.GaxProperties;
27+
import com.google.api.gax.grpc.ChannelPoolSettings;
2728
import com.google.api.gax.grpc.GrpcCallContext;
2829
import com.google.api.gax.grpc.GrpcTransportChannel;
2930
import com.google.api.gax.rpc.ClientContext;
@@ -74,9 +75,16 @@ public GrpcDatastoreRpc(DatastoreOptions datastoreOptions) throws IOException {
7475
? getClientContextForEmulator(datastoreOptions)
7576
: getClientContext(datastoreOptions);
7677

78+
//
7779
DatastoreStubSettings datastoreStubSettings =
7880
DatastoreStubSettings.newBuilder(clientContext)
7981
.applyToAllUnaryMethods(retrySettingSetter(datastoreOptions))
82+
.setTransportChannelProvider(DatastoreSettings.defaultGrpcTransportProviderBuilder()
83+
.setChannelPoolSettings(ChannelPoolSettings.builder()
84+
.setMinChannelCount(1)
85+
.setMaxChannelCount(4)
86+
.build())
87+
.build())
8088
.build();
8189
datastoreStub = GrpcDatastoreStub.create(datastoreStubSettings);
8290
} catch (IOException e) {

0 commit comments

Comments
 (0)