Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into feat/lro-wait
Browse files Browse the repository at this point in the history
  • Loading branch information
miraleung committed Feb 17, 2021
2 parents a1d113f + 348f136 commit a82b67e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
Expand Up @@ -411,6 +411,7 @@ private Builder(InstantiatingGrpcChannelProvider provider) {
this.credentials = provider.credentials;
this.channelPrimer = provider.channelPrimer;
this.attemptDirectPath = provider.attemptDirectPath;
this.directPathServiceConfig = provider.directPathServiceConfig;
}

/** Sets the number of available CPUs, used internally for testing. */
Expand Down
Expand Up @@ -157,6 +157,45 @@ public void testWithPoolSize() throws IOException {
}
}

@Test
public void testToBuilder() {
Duration keepaliveTime = Duration.ofSeconds(1);
Duration keepaliveTimeout = Duration.ofSeconds(2);
ApiFunction<ManagedChannelBuilder, ManagedChannelBuilder> channelConfigurator =
new ApiFunction<ManagedChannelBuilder, ManagedChannelBuilder>() {
@Override
public ManagedChannelBuilder apply(ManagedChannelBuilder input) {
throw new UnsupportedOperationException();
}
};
Map<String, ?> directPathServiceConfig = ImmutableMap.of("loadbalancingConfig", "grpclb");

InstantiatingGrpcChannelProvider provider =
InstantiatingGrpcChannelProvider.newBuilder()
.setProcessorCount(2)
.setEndpoint("fake.endpoint:443")
.setMaxInboundMessageSize(12345678)
.setMaxInboundMetadataSize(4096)
.setKeepAliveTime(keepaliveTime)
.setKeepAliveTimeout(keepaliveTimeout)
.setKeepAliveWithoutCalls(true)
.setChannelConfigurator(channelConfigurator)
.setChannelsPerCpu(2.5)
.setDirectPathServiceConfig(directPathServiceConfig)
.build();

InstantiatingGrpcChannelProvider.Builder builder = provider.toBuilder();

assertThat(builder.getEndpoint()).isEqualTo("fake.endpoint:443");
assertThat(builder.getMaxInboundMessageSize()).isEqualTo(12345678);
assertThat(builder.getMaxInboundMetadataSize()).isEqualTo(4096);
assertThat(builder.getKeepAliveTime()).isEqualTo(keepaliveTime);
assertThat(builder.getKeepAliveTimeout()).isEqualTo(keepaliveTimeout);
assertThat(builder.getChannelConfigurator()).isEqualTo(channelConfigurator);
assertThat(builder.getPoolSize()).isEqualTo(5);
assertThat(builder.build().directPathServiceConfig).isEqualTo(directPathServiceConfig);
}

@Test
public void testWithInterceptors() throws Exception {
testWithInterceptors(1);
Expand Down
2 changes: 1 addition & 1 deletion samples/pom.xml
Expand Up @@ -30,7 +30,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down

0 comments on commit a82b67e

Please sign in to comment.