- java.lang.Object
-
- io.helidon.grpc.server.GrpcServerImpl
-
- All Implemented Interfaces:
GrpcServer
public class GrpcServerImpl extends Object implements GrpcServer
A gRPC Server implementation.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.helidon.grpc.server.GrpcServer
GrpcServer.Builder
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GrpcServerConfigurationconfiguration()Gets effective server configuration.Contextcontext()Gets aGrpcServercontext.io.grpc.ManagedChannelcreateInProcessChannel()voiddeploy(ServiceDescriptor serviceDescriptor, PriorityBag<io.grpc.ServerInterceptor> globalInterceptors)Deploy the specifiedserviceto thisGrpcServer.List<io.grpc.ServerServiceDefinition>getServices()Obtain an immutableListof registeredServerServiceDefinitions.HealthCheck[]healthChecks()Return an array of health checks for this server.booleanisRunning()Returnstrueif the server is currently running.intport()Returns a port number the default server socket is bound to and is listening on; or-1if unknown or not active.Map<String,ServiceDescriptor>services()Obtain the deployed services.CompletionStage<GrpcServer>shutdown()Attempt to gracefully shutdown server.protected io.netty.handler.ssl.SslContextBuildersslContextBuilder(GrpcTlsDescriptor tlsConfig)Return an instance of SslContextBuilder from the specified SslConfig.CompletionStage<GrpcServer>start()Starts the server.voidundeploy(io.grpc.BindableService service, String sName)Undeploy the specifiedBindableServicefrom thisGrpcServerImpl.CompletionStage<GrpcServer>whenShutdown()Completion stage is completed when server is shut down.
-
-
-
Method Detail
-
start
public CompletionStage<GrpcServer> start()
Description copied from interface:GrpcServerStarts the server. Has no effect if server is running.- Specified by:
startin interfaceGrpcServer- Returns:
- a completion stage of starting process
-
shutdown
public CompletionStage<GrpcServer> shutdown()
Description copied from interface:GrpcServerAttempt to gracefully shutdown server. It is possible to use returnedCompletionStageto react.RequestMethod can be called periodically.
- Specified by:
shutdownin interfaceGrpcServer- Returns:
- to react on finished shutdown process
- See Also:
GrpcServer.start()
-
configuration
public GrpcServerConfiguration configuration()
Description copied from interface:GrpcServerGets effective server configuration.- Specified by:
configurationin interfaceGrpcServer- Returns:
- Server configuration
-
context
public Context context()
Description copied from interface:GrpcServerGets aGrpcServercontext.- Specified by:
contextin interfaceGrpcServer- Returns:
- a server context
-
whenShutdown
public CompletionStage<GrpcServer> whenShutdown()
Description copied from interface:GrpcServerCompletion stage is completed when server is shut down.- Specified by:
whenShutdownin interfaceGrpcServer- Returns:
- a completion stage of the server
-
isRunning
public boolean isRunning()
Description copied from interface:GrpcServerReturnstrueif the server is currently running. A running server in the stopping phase returnstrueuntil it is fully stopped.- Specified by:
isRunningin interfaceGrpcServer- Returns:
trueif server is running
-
port
public int port()
Description copied from interface:GrpcServerReturns a port number the default server socket is bound to and is listening on; or-1if unknown or not active.Only supported only when server is running.
- Specified by:
portin interfaceGrpcServer- Returns:
- a listen port; or
-1if unknown or the default server socket is not active
-
healthChecks
public HealthCheck[] healthChecks()
Description copied from interface:GrpcServerReturn an array of health checks for this server.- Specified by:
healthChecksin interfaceGrpcServer- Returns:
- an array of
HealthCheckinstances for this server
-
services
public Map<String,ServiceDescriptor> services()
Description copied from interface:GrpcServerObtain the deployed services.- Specified by:
servicesin interfaceGrpcServer- Returns:
- an immutable
Mapof deployedServiceDescriptors keyed by service name
-
deploy
public void deploy(ServiceDescriptor serviceDescriptor, PriorityBag<io.grpc.ServerInterceptor> globalInterceptors)
Deploy the specifiedserviceto thisGrpcServer.- Parameters:
serviceDescriptor- the service to deployglobalInterceptors- the globalServerInterceptors to wrap all services with- Throws:
NullPointerException- if any of the parameters isnull
-
undeploy
public void undeploy(io.grpc.BindableService service, String sName)Undeploy the specifiedBindableServicefrom thisGrpcServerImpl.- Parameters:
service- the service to undeploysName- the gRPC server name- Throws:
NullPointerException- ifserviceisnull
-
getServices
public List<io.grpc.ServerServiceDefinition> getServices()
Obtain an immutableListof registeredServerServiceDefinitions.- Returns:
- an immutable
Listof registeredServerServiceDefinitions
-
createInProcessChannel
public io.grpc.ManagedChannel createInProcessChannel()
- Returns:
- a new in-process
ManagedChannelfor interacting with the services managed by thisGrpcServerImpl.
-
sslContextBuilder
protected io.netty.handler.ssl.SslContextBuilder sslContextBuilder(GrpcTlsDescriptor tlsConfig)
Return an instance of SslContextBuilder from the specified SslConfig.- Parameters:
tlsConfig- the ssl configuration- Returns:
- an instance of SslContextBuilder
-
-