use of io.grpc.examples.helloworld.HelloRequest in project grpc-java by grpc.
the class CustomHeaderClient method greet.
/**
* A simple client method that like {@link io.grpc.examples.helloworld.HelloWorldClient}.
*/
private void greet(String name) {
logger.info("Will try to greet " + name + " ...");
HelloRequest request = HelloRequest.newBuilder().setName(name).build();
HelloReply response;
try {
response = blockingStub.sayHello(request);
} catch (StatusRuntimeException e) {
logger.log(Level.WARNING, "RPC failed: {0}", e.getStatus());
return;
}
logger.info("Greeting: " + response.getMessage());
}
use of io.grpc.examples.helloworld.HelloRequest in project grpc-java by grpc.
the class HedgingHelloWorldClient method greet.
/**
* Say hello to server.
*/
public void greet(String name) {
HelloRequest request = HelloRequest.newBuilder().setName(name).build();
HelloReply response = null;
StatusRuntimeException statusRuntimeException = null;
long startTime = System.nanoTime();
try {
response = blockingStub.sayHello(request);
} catch (StatusRuntimeException e) {
failedRpcs.incrementAndGet();
statusRuntimeException = e;
}
long latencyMills = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
latencies.offer(latencyMills);
if (statusRuntimeException == null) {
logger.log(Level.INFO, "Greeting: {0}. Latency: {1}ms", new Object[] { response.getMessage(), latencyMills });
} else {
logger.log(Level.INFO, "RPC failed: {0}. Latency: {1}ms", new Object[] { statusRuntimeException.getStatus(), latencyMills });
}
}
use of io.grpc.examples.helloworld.HelloRequest in project grpc-java by grpc.
the class RetryingHelloWorldClient method greet.
/**
* Say hello to server in a blocking unary call.
*/
public void greet(String name) {
HelloRequest request = HelloRequest.newBuilder().setName(name).build();
HelloReply response = null;
StatusRuntimeException statusRuntimeException = null;
try {
response = blockingStub.sayHello(request);
} catch (StatusRuntimeException e) {
failedRpcs.incrementAndGet();
statusRuntimeException = e;
}
totalRpcs.incrementAndGet();
if (statusRuntimeException == null) {
logger.log(Level.INFO, "Greeting: {0}", new Object[] { response.getMessage() });
} else {
logger.log(Level.INFO, "RPC failed: {0}", new Object[] { statusRuntimeException.getStatus() });
}
}
use of io.grpc.examples.helloworld.HelloRequest in project grpc-java by grpc.
the class SafeMethodCachingInterceptorTest method differentServiceCallsAreNotConflated.
@Test
public void differentServiceCallsAreNotConflated() {
MethodDescriptor<HelloRequest, HelloReply> anotherSafeMethod = AnotherGreeterGrpc.getSayHelloMethod().toBuilder().setSafe(true).build();
HelloReply reply1 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT, message);
HelloReply reply2 = ClientCalls.blockingUnaryCall(channelToUse, anotherSafeMethod, CallOptions.DEFAULT, message);
assertNotEquals(reply1, reply2);
}
use of io.grpc.examples.helloworld.HelloRequest in project grpc-java by grpc.
the class SafeMethodCachingInterceptorTest method differentMethodCallsAreNotConflated.
@Test
public void differentMethodCallsAreNotConflated() {
MethodDescriptor<HelloRequest, HelloReply> anotherSafeMethod = GreeterGrpc.getSayAnotherHelloMethod().toBuilder().setSafe(true).build();
HelloReply reply1 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT, message);
HelloReply reply2 = ClientCalls.blockingUnaryCall(channelToUse, anotherSafeMethod, CallOptions.DEFAULT, message);
assertNotEquals(reply1, reply2);
}
Aggregations