- All Known Implementing Classes:
GrpcServerImpl
public interface GrpcServer
Represents a immutably configured gRPC server.
Provides a basic lifecycle and monitoring API.
Instance can be created from GrpcRouting and optionally from GrpcServerConfiguration using create(GrpcRouting), create(GrpcServerConfiguration, GrpcRouting) or builder(GrpcRouting) methods
and their builder enabled overloads.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classGrpcServer builder class provides a convenient way to timed a GrpcServer instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic GrpcServer.Builderbuilder(GrpcRouting routing) Creates a builder of theGrpcServer.static GrpcServer.Builderbuilder(Supplier<? extends GrpcRouting> routingBuilder) Creates a builder of theGrpcServer.Gets effective server configuration.context()Gets aGrpcServercontext.static GrpcServercreate(GrpcRouting routing) Creates new instance form provided GrpcRouting and default configuration.static GrpcServercreate(GrpcServerConfiguration configuration, GrpcRouting routing) Creates new instance form provided configuration and GrpcRouting.static GrpcServercreate(GrpcServerConfiguration configuration, Supplier<? extends GrpcRouting> routingBuilder) Creates new instance form provided configuration and GrpcRouting.static GrpcServercreate(Supplier<? extends GrpcRouting> routingBuilder) Creates new instance form provided GrpcRouting and default configuration.static GrpcServercreate(Supplier<? extends GrpcServerConfiguration> configurationBuilder, GrpcRouting routing) Creates a new instance from a provided configuration and a GrpcRouting.static GrpcServercreate(Supplier<? extends GrpcServerConfiguration> configurationBuilder, Supplier<? extends GrpcRouting> routingBuilder) Creates new instance form provided configuration and GrpcRouting.Return an array of health checks for this server.booleanReturnstrueif 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.services()Obtain the deployed services.shutdown()Attempt to gracefully shutdown server.start()Starts the server.Completion stage is completed when server is shut down.
-
Method Details
-
configuration
GrpcServerConfiguration configuration()Gets effective server configuration.- Returns:
- Server configuration
-
context
Context context()Gets aGrpcServercontext.- Returns:
- a server context
-
start
CompletionStage<GrpcServer> start()Starts the server. Has no effect if server is running.- Returns:
- a completion stage of starting process
-
whenShutdown
CompletionStage<GrpcServer> whenShutdown()Completion stage is completed when server is shut down.- Returns:
- a completion stage of the server
-
shutdown
CompletionStage<GrpcServer> shutdown()Attempt to gracefully shutdown server. It is possible to use returnedCompletionStageto react.RequestMethod can be called periodically.
- Returns:
- to react on finished shutdown process
- See Also:
-
healthChecks
HealthCheck[] healthChecks()Return an array of health checks for this server.- Returns:
- an array of
HealthCheckinstances for this server
-
services
Map<String,ServiceDescriptor> services()Obtain the deployed services.- Returns:
- an immutable
Mapof deployedServiceDescriptors keyed by service name
-
isRunning
boolean isRunning()Returnstrueif the server is currently running. A running server in the stopping phase returnstrueuntil it is fully stopped.- Returns:
trueif server is running
-
port
int port()Returns 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.
- Returns:
- a listen port; or
-1if unknown or the default server socket is not active
-
create
static GrpcServer create(Supplier<? extends GrpcServerConfiguration> configurationBuilder, GrpcRouting routing) Creates a new instance from a provided configuration and a GrpcRouting.- Parameters:
configurationBuilder- a server configuration builder that will be built as a first step of this method execution; may benullrouting- a GrpcRouting instance- Returns:
- a new gRPC server instance
- Throws:
IllegalStateException- if none SPI implementation foundNullPointerException- if 'GrpcRouting' parameter isnull
-
create
static GrpcServer create(Supplier<? extends GrpcServerConfiguration> configurationBuilder, Supplier<? extends GrpcRouting> routingBuilder) Creates new instance form provided configuration and GrpcRouting.- Parameters:
configurationBuilder- a server configuration builder that will be built as a first step of this method execution; may benullroutingBuilder- a GrpcRouting builder that will be built as a second step of this method execution- Returns:
- a new gRPC server instance
- Throws:
IllegalStateException- if none SPI implementation foundNullPointerException- if 'routingBuilder' parameter isnull
-
create
static GrpcServer create(GrpcServerConfiguration configuration, Supplier<? extends GrpcRouting> routingBuilder) Creates new instance form provided configuration and GrpcRouting.- Parameters:
configuration- a server configuration instanceroutingBuilder- a GrpcRouting builder that will be built as a second step of this method execution- Returns:
- a new gRPC server instance
- Throws:
IllegalStateException- if none SPI implementation foundNullPointerException- if 'routingBuilder' parameter isnull
-
create
Creates new instance form provided GrpcRouting and default configuration.- Parameters:
routing- a GrpcRouting instance- Returns:
- a new gRPC server instance
- Throws:
IllegalStateException- if none SPI implementation foundNullPointerException- if 'routing' parameter isnull
-
create
Creates new instance form provided configuration and GrpcRouting.- Parameters:
configuration- a server configuration instancerouting- a GrpcRouting instance- Returns:
- a new gRPC server instance
- Throws:
IllegalStateException- if none SPI implementation foundNullPointerException- if 'GrpcRouting' parameter isnull
-
create
Creates new instance form provided GrpcRouting and default configuration.- Parameters:
routingBuilder- a GrpcRouting builder instance that will be built as a first step of this method execution- Returns:
- a new gRPC server instance
- Throws:
IllegalStateException- if none SPI implementation foundNullPointerException- if 'GrpcRouting' parameter isnull
-
builder
Creates a builder of theGrpcServer.- Parameters:
routingBuilder- the GrpcRouting builder; must not benull- Returns:
- the builder
-
builder
Creates a builder of theGrpcServer.- Parameters:
routing- the GrpcRouting; must not benull- Returns:
- the builder
-