Skip to content

Commit 765f311

Browse files
committed
Add constants for min, max and init channel count
1 parent 2495036 commit 765f311

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ public class DatastoreOptions extends ServiceOptions<Datastore, DatastoreOptions
5151
private static final String DEFAULT_DATABASE_ID = "";
5252
public static final String PROJECT_ID_ENV_VAR = "DATASTORE_PROJECT_ID";
5353
public static final String LOCAL_HOST_ENV_VAR = "DATASTORE_EMULATOR_HOST";
54+
public static final int INIT_CHANNEL_COUNT = 1;
55+
public static final int MIN_CHANNEL_COUNT = 1;
56+
public static final int MAX_CHANNEL_COUNT = 4;
5457

5558
private transient TransportChannelProvider channelProvider = null;
5659

@@ -228,8 +231,9 @@ private DatastoreOptions(Builder builder) {
228231
DatastoreSettings.defaultGrpcTransportProviderBuilder()
229232
.setChannelPoolSettings(
230233
ChannelPoolSettings.builder()
231-
.setMinChannelCount(1)
232-
.setMaxChannelCount(4)
234+
.setInitialChannelCount(INIT_CHANNEL_COUNT)
235+
.setMinChannelCount(MIN_CHANNEL_COUNT)
236+
.setMaxChannelCount(MAX_CHANNEL_COUNT)
233237
.build()),
234238
this);
235239
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ public GrpcDatastoreRpc(DatastoreOptions datastoreOptions) throws IOException {
8383
DatastoreSettings.defaultGrpcTransportProviderBuilder()
8484
.setChannelPoolSettings(
8585
ChannelPoolSettings.builder()
86-
.setMinChannelCount(1)
87-
.setMaxChannelCount(4)
86+
.setInitialChannelCount(DatastoreOptions.INIT_CHANNEL_COUNT)
87+
.setMinChannelCount(DatastoreOptions.MIN_CHANNEL_COUNT)
88+
.setMaxChannelCount(DatastoreOptions.MAX_CHANNEL_COUNT)
8889
.build())
8990
.build())
9091
.build();

google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreOptionsTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ public void testGrpcDefaultChannelConfigurations() {
117117
ChannelPoolSettings channelPoolSettings =
118118
((InstantiatingGrpcChannelProvider) datastoreOptions.getTransportChannelProvider())
119119
.getChannelPoolSettings();
120-
assertEquals(channelPoolSettings.getInitialChannelCount(), 1);
121-
assertEquals(channelPoolSettings.getMinChannelCount(), 1);
122-
assertEquals(channelPoolSettings.getMaxChannelCount(), 4);
120+
assertEquals(channelPoolSettings.getInitialChannelCount(), DatastoreOptions.INIT_CHANNEL_COUNT);
121+
assertEquals(channelPoolSettings.getMinChannelCount(), DatastoreOptions.MIN_CHANNEL_COUNT);
122+
assertEquals(channelPoolSettings.getMaxChannelCount(), DatastoreOptions.MAX_CHANNEL_COUNT);
123123
}
124124

125125
@Test

0 commit comments

Comments
 (0)