- 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 GrpcServerConfiguration
configuration()
Gets effective server configuration.Context
context()
Gets aGrpcServer
context.io.grpc.ManagedChannel
createInProcessChannel()
void
deploy(ServiceDescriptor serviceDescriptor, PriorityBag<io.grpc.ServerInterceptor> globalInterceptors)
Deploy the specifiedservice
to thisGrpcServer
.List<io.grpc.ServerServiceDefinition>
getServices()
Obtain an immutableList
of registeredServerServiceDefinition
s.HealthCheck[]
healthChecks()
Return an array of health checks for this server.boolean
isRunning()
Returnstrue
if the server is currently running.int
port()
Returns a port number the default server socket is bound to and is listening on; or-1
if 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.SslContextBuilder
sslContextBuilder(GrpcTlsDescriptor tlsConfig)
Return an instance of SslContextBuilder from the specified SslConfig.CompletionStage<GrpcServer>
start()
Starts the server.void
undeploy(io.grpc.BindableService service, String sName)
Undeploy the specifiedBindableService
from thisGrpcServerImpl
.CompletionStage<GrpcServer>
whenShutdown()
Completion stage is completed when server is shut down.
-
-
-
Method Detail
-
start
public CompletionStage<GrpcServer> start()
Description copied from interface:GrpcServer
Starts the server. Has no effect if server is running.- Specified by:
start
in interfaceGrpcServer
- Returns:
- a completion stage of starting process
-
shutdown
public CompletionStage<GrpcServer> shutdown()
Description copied from interface:GrpcServer
Attempt to gracefully shutdown server. It is possible to use returnedCompletionStage
to react.RequestMethod can be called periodically.
- Specified by:
shutdown
in interfaceGrpcServer
- Returns:
- to react on finished shutdown process
- See Also:
GrpcServer.start()
-
configuration
public GrpcServerConfiguration configuration()
Description copied from interface:GrpcServer
Gets effective server configuration.- Specified by:
configuration
in interfaceGrpcServer
- Returns:
- Server configuration
-
context
public Context context()
Description copied from interface:GrpcServer
Gets aGrpcServer
context.- Specified by:
context
in interfaceGrpcServer
- Returns:
- a server context
-
whenShutdown
public CompletionStage<GrpcServer> whenShutdown()
Description copied from interface:GrpcServer
Completion stage is completed when server is shut down.- Specified by:
whenShutdown
in interfaceGrpcServer
- Returns:
- a completion stage of the server
-
isRunning
public boolean isRunning()
Description copied from interface:GrpcServer
Returnstrue
if the server is currently running. A running server in the stopping phase returnstrue
until it is fully stopped.- Specified by:
isRunning
in interfaceGrpcServer
- Returns:
true
if server is running
-
port
public int port()
Description copied from interface:GrpcServer
Returns a port number the default server socket is bound to and is listening on; or-1
if unknown or not active.Only supported only when server is running.
- Specified by:
port
in interfaceGrpcServer
- Returns:
- a listen port; or
-1
if unknown or the default server socket is not active
-
healthChecks
public HealthCheck[] healthChecks()
Description copied from interface:GrpcServer
Return an array of health checks for this server.- Specified by:
healthChecks
in interfaceGrpcServer
- Returns:
- an array of
HealthCheck
instances for this server
-
services
public Map<String,ServiceDescriptor> services()
Description copied from interface:GrpcServer
Obtain the deployed services.- Specified by:
services
in interfaceGrpcServer
- Returns:
- an immutable
Map
of deployedServiceDescriptor
s keyed by service name
-
deploy
public void deploy(ServiceDescriptor serviceDescriptor, PriorityBag<io.grpc.ServerInterceptor> globalInterceptors)
Deploy the specifiedservice
to thisGrpcServer
.- Parameters:
serviceDescriptor
- the service to deployglobalInterceptors
- the globalServerInterceptor
s 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 specifiedBindableService
from thisGrpcServerImpl
.- Parameters:
service
- the service to undeploysName
- the gRPC server name- Throws:
NullPointerException
- ifservice
isnull
-
getServices
public List<io.grpc.ServerServiceDefinition> getServices()
Obtain an immutableList
of registeredServerServiceDefinition
s.- Returns:
- an immutable
List
of registeredServerServiceDefinition
s
-
createInProcessChannel
public io.grpc.ManagedChannel createInProcessChannel()
- Returns:
- a new in-process
ManagedChannel
for 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
-
-