use of io.grpc.examples.helloworld.HelloRequest in project vertx-examples by vert-x3.
the class Client method start.
@Override
public void start() throws Exception {
ManagedChannel channel = VertxChannelBuilder.forAddress(vertx, "localhost", 8080).useSsl(options -> options.setSsl(true).setUseAlpn(true).setTrustStoreOptions(new JksOptions().setPath("tls/client-truststore.jks").setPassword("wibble"))).build();
GreeterGrpc.GreeterVertxStub stub = GreeterGrpc.newVertxStub(channel);
HelloRequest request = HelloRequest.newBuilder().setName("Julien").build();
stub.sayHello(request, asyncResponse -> {
if (asyncResponse.succeeded()) {
System.out.println("Succeeded " + asyncResponse.result().getMessage());
} else {
asyncResponse.cause().printStackTrace();
}
});
}
use of io.grpc.examples.helloworld.HelloRequest in project vertx-examples by vert-x3.
the class Client method start.
@Override
public void start() throws Exception {
ManagedChannel channel = VertxChannelBuilder.forAddress(vertx, "localhost", 8080).usePlaintext(true).build();
GreeterGrpc.GreeterVertxStub stub = GreeterGrpc.newVertxStub(channel);
HelloRequest request = HelloRequest.newBuilder().setName("Julien").build();
stub.sayHello(request, asyncResponse -> {
if (asyncResponse.succeeded()) {
System.out.println("Succeeded " + asyncResponse.result().getMessage());
} else {
asyncResponse.cause().printStackTrace();
}
});
}
use of io.grpc.examples.helloworld.HelloRequest in project vertx-openshift-it by cescoffier.
the class EdgeVerticle method grpc.
private void grpc(RoutingContext rc) {
ManagedChannel channel = VertxChannelBuilder.forAddress(vertx, "hello", 8082).useSsl(options -> options.setSsl(true).setUseAlpn(true).setTrustAll(true)).build();
GreeterGrpc.GreeterVertxStub stub = GreeterGrpc.newVertxStub(channel);
HelloRequest request = HelloRequest.newBuilder().setName("OpenShift").build();
System.out.println("Sending request...");
stub.sayHello(request, asyncResponse -> {
System.out.println("Got result");
if (asyncResponse.succeeded()) {
System.out.println("Succeeded " + asyncResponse.result().getMessage());
rc.response().end(asyncResponse.result().getMessage());
} else {
rc.fail(asyncResponse.cause());
}
});
}
use of io.grpc.examples.helloworld.HelloRequest in project vertx-openshift-it by cescoffier.
the class Http2IT method testGRPC.
@Test
public void testGRPC() throws Exception {
Assertions.assertThat(client).deployments().pods().isPodReadyForPeriod();
String host = securedUrlForRoute(client.routes().withName("hello").get()).getHost();
System.out.println("Host: " + host);
System.out.println("Port: " + 443);
ManagedChannel channel = VertxChannelBuilder.forAddress(vertx, host, 443).useSsl(options -> options.setSsl(true).setUseAlpn(true).setTrustAll(true)).build();
GreeterGrpc.GreeterVertxStub stub = GreeterGrpc.newVertxStub(channel);
HelloRequest request = HelloRequest.newBuilder().setName("OpenShift").build();
AtomicReference<String> result = new AtomicReference<>();
System.out.println("Sending request...");
stub.sayHello(request, asyncResponse -> {
System.out.println("Got result");
if (asyncResponse.succeeded()) {
System.out.println("Succeeded " + asyncResponse.result().getMessage());
result.set(asyncResponse.result().getMessage());
} else {
asyncResponse.cause().printStackTrace();
}
});
await().atMost(5, TimeUnit.MINUTES).untilAtomic(result, is(notNullValue()));
assertThat(result.get()).contains("Hello OpenShift");
}
use of io.grpc.examples.helloworld.HelloRequest in project pinpoint by naver.
the class HelloWorldSimpleClient method greet.
public String greet(String name) {
HelloRequest request = HelloRequest.newBuilder().setName(name).build();
HelloReply response = blockingStub.sayHello(request);
logger.info("Greeting: {}" + response.getMessage());
return response.getMessage();
}
Aggregations