Interface GrpcServer

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.

  • Method Details

    • configuration

      GrpcServerConfiguration configuration()
      Gets effective server configuration.
      Returns:
      Server configuration
    • context

      Context context()
      Gets a GrpcServer context.
      Returns:
      a server context
    • 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

      Attempt to gracefully shutdown server. It is possible to use returned CompletionStage to 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 HealthCheck instances for this server
    • services

      Obtain the deployed services.
      Returns:
      an immutable Map of deployed ServiceDescriptors keyed by service name
    • isRunning

      boolean isRunning()
      Returns true if the server is currently running. A running server in the stopping phase returns true 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 be null
      routing - a GrpcRouting instance
      Returns:
      a new gRPC server instance
      Throws:
      IllegalStateException - if none SPI implementation found
      NullPointerException - if 'GrpcRouting' parameter is null
    • 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 be null
      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 found
      NullPointerException - if 'routingBuilder' parameter is null
    • create

      static GrpcServer create(GrpcServerConfiguration configuration, Supplier<? extends GrpcRouting> routingBuilder)
      Creates new instance form provided configuration and GrpcRouting.
      Parameters:
      configuration - a server configuration instance
      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 found
      NullPointerException - if 'routingBuilder' parameter is null
    • 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 found
      NullPointerException - if 'routing' parameter is null
    • create

      static GrpcServer create(GrpcServerConfiguration configuration, GrpcRouting routing)
      Creates new instance form provided configuration and GrpcRouting.
      Parameters:
      configuration - a server configuration instance
      routing - a GrpcRouting instance
      Returns:
      a new gRPC server instance
      Throws:
      IllegalStateException - if none SPI implementation found
      NullPointerException - if 'GrpcRouting' parameter is null
    • 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 found
      NullPointerException - if 'GrpcRouting' parameter is null
    • builder

      static GrpcServer.Builder builder(Supplier<? extends GrpcRouting> routingBuilder)
      Creates a builder of the GrpcServer.
      Parameters:
      routingBuilder - the GrpcRouting builder; must not be null
      Returns:
      the builder
    • builder

      static GrpcServer.Builder builder(GrpcRouting routing)
      Creates a builder of the GrpcServer.
      Parameters:
      routing - the GrpcRouting; must not be null
      Returns:
      the builder