Module io.inverno.mod.grpc.server


module io.inverno.mod.grpc.server

The Inverno framework gRPC server module provides a gRPC server.

It defines the following sockets:

configuration
the gRPC server module configuration
netService (required)
the Net service providing the ByteBuf allocator
messageCompressors
custom gRPC message compressors

It exposes the following beans:

configuration
the gRPC server module configuration
grpcServer
the gRPC server

A simple gRPC server can be started with an HTTP/2 server by transforming server HTTPexchange handler into a server gRPC exchange handler as follows:


 GrpcServer grpcServer = ...
 NetService netService = ...
 ResourceService resourceService = ...
 		
 Application.with(new Server.Builder(netService, resourceService)
     .setConfiguration(HttpServerConfigurationLoader.load(conf -> conf.server_port(8080).h2_enabled(true)))
     .setController(ServerController.from(
         grpcServer.unary(
             HelloRequest.getDefaultInstance(), 
             HelloReply.getDefaultInstance(), 
             (GrpcExchange.Unary<ExchangeContext, HelloRequest, HelloReply> grpcExchange) -> {
                 grpcExchange.response().value(
                     grpcExchange.request().value().map(request -> HelloReply.newBuilder().setMessage("Hello " + request.getName()).build())
                 );
             }
         )
     ))
 ).run();
 
Since:
1.9
Author:
Jeremy Kuhn