-
- 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 fromGrpcServerConfiguration
usingcreate(GrpcRouting)
,create(GrpcServerConfiguration, GrpcRouting)
orbuilder(GrpcRouting)
methods and their builder enabled overloads.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
GrpcServer.Builder
GrpcServer 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.Builder
builder(GrpcRouting routing)
Creates a builder of theGrpcServer
.static GrpcServer.Builder
builder(Supplier<? extends GrpcRouting> routingBuilder)
Creates a builder of theGrpcServer
.GrpcServerConfiguration
configuration()
Gets effective server configuration.Context
context()
Gets aGrpcServer
context.static GrpcServer
create(GrpcRouting routing)
Creates new instance form provided GrpcRouting and default configuration.static GrpcServer
create(GrpcServerConfiguration configuration, GrpcRouting routing)
Creates new instance form provided configuration and GrpcRouting.static GrpcServer
create(GrpcServerConfiguration configuration, Supplier<? extends GrpcRouting> routingBuilder)
Creates new instance form provided configuration and GrpcRouting.static GrpcServer
create(Supplier<? extends GrpcRouting> routingBuilder)
Creates new instance form provided GrpcRouting and default configuration.static GrpcServer
create(Supplier<? extends GrpcServerConfiguration> configurationBuilder, GrpcRouting routing)
Creates a new instance from a provided configuration and a GrpcRouting.static GrpcServer
create(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.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.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 aGrpcServer
context.- 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 returnedCompletionStage
to 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
HealthCheck
instances for this server
-
services
Map<String,ServiceDescriptor> services()
Obtain the deployed services.- Returns:
- an immutable
Map
of deployedServiceDescriptor
s keyed by service name
-
isRunning
boolean isRunning()
Returnstrue
if the server is currently running. A running server in the stopping phase returnstrue
until it is fully stopped.- Returns:
true
if server is running
-
port
int port()
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.
- Returns:
- a listen port; or
-1
if 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 benull
routing
- 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 benull
routingBuilder
- 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
-
-