Java Code Examples for io.grpc.netty.NettyChannelBuilder#enableFullStreamDecompression()
The following examples show how to use
io.grpc.netty.NettyChannelBuilder#enableFullStreamDecompression() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestServiceClient.java From grpc-nebula-java with Apache License 2.0 | 4 votes |
@Override protected ManagedChannel createChannel() { if (customCredentialsType != null && customCredentialsType.equals("google_default_credentials")) { return GoogleDefaultChannelBuilder.forAddress(serverHost, serverPort).build(); } if (useAlts) { return AltsChannelBuilder.forAddress(serverHost, serverPort).build(); } AbstractManagedChannelImplBuilder<?> builder; if (!useOkHttp) { SslContext sslContext = null; if (useTestCa) { try { sslContext = GrpcSslContexts.forClient().trustManager( TestUtils.loadCert("ca.pem")).build(); } catch (Exception ex) { throw new RuntimeException(ex); } } NettyChannelBuilder nettyBuilder = NettyChannelBuilder.forAddress(serverHost, serverPort) .flowControlWindow(65 * 1024) .negotiationType(useTls ? NegotiationType.TLS : NegotiationType.PLAINTEXT) .sslContext(sslContext); if (serverHostOverride != null) { nettyBuilder.overrideAuthority(serverHostOverride); } if (fullStreamDecompression) { nettyBuilder.enableFullStreamDecompression(); } builder = nettyBuilder; } else { OkHttpChannelBuilder okBuilder = OkHttpChannelBuilder.forAddress(serverHost, serverPort); if (serverHostOverride != null) { // Force the hostname to match the cert the server uses. okBuilder.overrideAuthority( GrpcUtil.authorityFromHostAndPort(serverHostOverride, serverPort)); } if (useTls) { try { SSLSocketFactory factory = useTestCa ? TestUtils.newSslSocketFactoryForCa(Platform.get().getProvider(), TestUtils.loadCert("ca.pem")) : (SSLSocketFactory) SSLSocketFactory.getDefault(); okBuilder.sslSocketFactory(factory); } catch (Exception e) { throw new RuntimeException(e); } } else { okBuilder.usePlaintext(); } if (fullStreamDecompression) { okBuilder.enableFullStreamDecompression(); } builder = okBuilder; } io.grpc.internal.TestingAccessor.setStatsImplementation( builder, createClientCensusStatsModule()); return builder.build(); }
Example 2
Source File: TestServiceClient.java From grpc-java with Apache License 2.0 | 4 votes |
@Override protected ManagedChannel createChannel() { if (customCredentialsType != null && customCredentialsType.equals("google_default_credentials")) { return GoogleDefaultChannelBuilder.forAddress(serverHost, serverPort).build(); } if (customCredentialsType != null && customCredentialsType.equals("compute_engine_channel_creds")) { return ComputeEngineChannelBuilder.forAddress(serverHost, serverPort).build(); } if (useAlts) { return AltsChannelBuilder.forAddress(serverHost, serverPort).build(); } AbstractManagedChannelImplBuilder<?> builder; if (!useOkHttp) { SslContext sslContext = null; if (useTestCa) { try { sslContext = GrpcSslContexts.forClient().trustManager( TestUtils.loadCert("ca.pem")).build(); } catch (Exception ex) { throw new RuntimeException(ex); } } NettyChannelBuilder nettyBuilder = NettyChannelBuilder.forAddress(serverHost, serverPort) .flowControlWindow(65 * 1024) .negotiationType(useTls ? NegotiationType.TLS : (useH2cUpgrade ? NegotiationType.PLAINTEXT_UPGRADE : NegotiationType.PLAINTEXT)) .sslContext(sslContext); if (serverHostOverride != null) { nettyBuilder.overrideAuthority(serverHostOverride); } if (fullStreamDecompression) { nettyBuilder.enableFullStreamDecompression(); } builder = nettyBuilder; } else { OkHttpChannelBuilder okBuilder = OkHttpChannelBuilder.forAddress(serverHost, serverPort); if (serverHostOverride != null) { // Force the hostname to match the cert the server uses. okBuilder.overrideAuthority( GrpcUtil.authorityFromHostAndPort(serverHostOverride, serverPort)); } if (useTls) { if (useTestCa) { try { SSLSocketFactory factory = TestUtils.newSslSocketFactoryForCa( Platform.get().getProvider(), TestUtils.loadCert("ca.pem")); okBuilder.sslSocketFactory(factory); } catch (Exception e) { throw new RuntimeException(e); } } } else { okBuilder.usePlaintext(); } if (fullStreamDecompression) { okBuilder.enableFullStreamDecompression(); } builder = okBuilder; } // Disable the default census stats interceptor, use testing interceptor instead. io.grpc.internal.TestingAccessor.setStatsEnabled(builder, false); return builder.intercept(createCensusStatsClientInterceptor()).build(); }