use of io.grpc.examples.helloworld.Greeter.ClientFactory in project servicetalk by apple.
the class GrpcUdsTest method udsRoundTrip.
@Test
void udsRoundTrip() throws Exception {
Assumptions.assumeTrue(ioExecutor.isUnixDomainSocketSupported());
String greetingPrefix = "Hello ";
String name = "foo";
String expectedResponse = greetingPrefix + name;
try (ServerContext serverContext = forAddress(newSocketAddress()).initializeHttp(builder -> builder.ioExecutor(ioExecutor)).listenAndAwait((GreeterService) (ctx, request) -> succeeded(HelloReply.newBuilder().setMessage(greetingPrefix + request.getName()).build()));
BlockingGreeterClient client = forResolvedAddress(serverContext.listenAddress()).buildBlocking(new ClientFactory())) {
assertEquals(expectedResponse, client.sayHello(HelloRequest.newBuilder().setName(name).build()).getMessage());
}
}
use of io.grpc.examples.helloworld.Greeter.ClientFactory in project servicetalk by apple.
the class BlockingHelloWorldClient method main.
public static void main(String[] args) throws Exception {
try (BlockingGreeterClient client = GrpcClients.forAddress("localhost", 8080).buildBlocking(new ClientFactory())) {
HelloReply reply = client.sayHello(HelloRequest.newBuilder().setName("World").build());
System.out.println(reply);
}
}
Aggregations