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:
- netService (required)
- the Net service providing the ByteBuf allocator
- configuration
- the gRPC server module configuration
- extensionRegistry
- the Protocol buffer extension registry
- 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();
Note that in above example, all requests sent to the server are processed with the same handler, the io.inverno.mod.web.server
is better suited to route requests based on gRPC service and
method names. It is recommended to rely on a protoc plugin for generating a proper gRPC Web routes
configurer from Protocol buffer definitions.
- Since:
- 1.9
- Author:
- Jeremy Kuhn
-
Packages
FromPackagesio.inverno.mod.base io.inverno.mod.base.concurrent io.inverno.mod.base.converter io.inverno.mod.base.net io.inverno.mod.base.reflect io.inverno.mod.base.resource -
Modules
ModifierModuleDescriptiontransitiveDefines the foundational APIs of the Inverno framework modules.transitiveThe Inverno framework configuration module provides advanced application configuration capabilities.transitiveThe Inverno framework gRPC base module defines the base APIs and services for gRPC client and server implementations.transitiveThe Inverno framework HTTP base module defines base APIs and services for HTTP client and server implementations.transitiveThe Inverno framework HTTP server module provides an HTTP1.x and HTTP/2 server.