mirror of https://github.com/grpc/grpc-java.git
examples: Modify the way of getHedgingServiceConfig in io.grpc.examples.hedging.HedgingHelloWorldClient (#7700)
This commit is contained in:
parent
26e88d9326
commit
f5865d5bf2
|
|
@ -51,21 +51,21 @@ public class HedgingHelloWorldClient {
|
||||||
|
|
||||||
/** Construct client connecting to HelloWorld server at {@code host:port}. */
|
/** Construct client connecting to HelloWorld server at {@code host:port}. */
|
||||||
public HedgingHelloWorldClient(String host, int port, boolean hedging) {
|
public HedgingHelloWorldClient(String host, int port, boolean hedging) {
|
||||||
Map<String, ?> hedgingServiceConfig =
|
|
||||||
new Gson()
|
|
||||||
.fromJson(
|
|
||||||
new JsonReader(
|
|
||||||
new InputStreamReader(
|
|
||||||
HedgingHelloWorldClient.class.getResourceAsStream(
|
|
||||||
"hedging_service_config.json"),
|
|
||||||
UTF_8)),
|
|
||||||
Map.class);
|
|
||||||
|
|
||||||
ManagedChannelBuilder<?> channelBuilder = ManagedChannelBuilder.forAddress(host, port)
|
ManagedChannelBuilder<?> channelBuilder = ManagedChannelBuilder.forAddress(host, port)
|
||||||
// Channels are secure by default (via SSL/TLS). For the example we disable TLS to avoid
|
// Channels are secure by default (via SSL/TLS). For the example we disable TLS to avoid
|
||||||
// needing certificates.
|
// needing certificates.
|
||||||
.usePlaintext();
|
.usePlaintext();
|
||||||
if (hedging) {
|
if (hedging) {
|
||||||
|
Map<String, ?> hedgingServiceConfig =
|
||||||
|
new Gson()
|
||||||
|
.fromJson(
|
||||||
|
new JsonReader(
|
||||||
|
new InputStreamReader(
|
||||||
|
HedgingHelloWorldClient.class.getResourceAsStream(
|
||||||
|
"hedging_service_config.json"),
|
||||||
|
UTF_8)),
|
||||||
|
Map.class);
|
||||||
channelBuilder.defaultServiceConfig(hedgingServiceConfig).enableRetry();
|
channelBuilder.defaultServiceConfig(hedgingServiceConfig).enableRetry();
|
||||||
}
|
}
|
||||||
channel = channelBuilder.build();
|
channel = channelBuilder.build();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue