-
- All Known Implementing Classes:
GrpcServerImpl
public interface GrpcServerRepresents a immutably configured gRPC server.Provides a basic lifecycle and monitoring API.
Instance can be created from
GrpcRoutingand optionally fromGrpcServerConfigurationusingcreate(GrpcRouting),create(GrpcServerConfiguration, GrpcRouting)orbuilder(GrpcRouting)methods and their builder enabled overloads.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classGrpcServer.BuilderGrpcServer builder class provides a convenient way to timed a GrpcServer instance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static GrpcServer.Builderbuilder(GrpcRouting routing)Creates a builder of theGrpcServer.static GrpcServer.Builderbuilder(Supplier<? extends GrpcRouting> routingBuilder)Creates a builder of theGrpcServer.GrpcServerConfigurationconfiguration()Gets effective server configuration.Contextcontext()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.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.CompletionStage<GrpcServer>start()Starts the server.CompletionStage<GrpcServer>whenShutdown()Completion stage is completed when server is shut down.
-
-
-
Method Detail
-
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:
start()
-
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
static GrpcServer create(GrpcRouting routing)
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
static GrpcServer create(GrpcServerConfiguration configuration, GrpcRouting routing)
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
static GrpcServer create(Supplier<? extends GrpcRouting> routingBuilder)
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
static GrpcServer.Builder builder(Supplier<? extends GrpcRouting> routingBuilder)
Creates a builder of theGrpcServer.- Parameters:
routingBuilder- the GrpcRouting builder; must not benull- Returns:
- the builder
-
builder
static GrpcServer.Builder builder(GrpcRouting routing)
Creates a builder of theGrpcServer.- Parameters:
routing- the GrpcRouting; must not benull- Returns:
- the builder
-
-