Class GrpcServerLifecycle

java.lang.Object
net.devh.boot.grpc.server.serverfactory.GrpcServerLifecycle
All Implemented Interfaces:
Lifecycle, Phased, SmartLifecycle

public class GrpcServerLifecycle extends Object implements SmartLifecycle
Lifecycle bean that automatically starts and stops the grpc server.
  • Constructor Details

    • GrpcServerLifecycle

      public GrpcServerLifecycle(GrpcServerFactory factory, Duration shutdownGracePeriod, ApplicationEventPublisher eventPublisher)
      Creates a new GrpcServerLifecycle
      Parameters:
      factory - The server factory to use.
      shutdownGracePeriod - The time to wait for the server to gracefully shut down.
      eventPublisher - The event publisher to use.
  • Method Details

    • start

      public void start()
      Specified by:
      start in interface Lifecycle
    • stop

      public void stop()
      Specified by:
      stop in interface Lifecycle
    • stop

      public void stop(Runnable callback)
      Specified by:
      stop in interface SmartLifecycle
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface Lifecycle
    • getPhase

      public int getPhase()
      Specified by:
      getPhase in interface Phased
      Specified by:
      getPhase in interface SmartLifecycle
    • isAutoStartup

      public boolean isAutoStartup()
      Specified by:
      isAutoStartup in interface SmartLifecycle
    • createAndStartGrpcServer

      protected void createAndStartGrpcServer() throws IOException
      Creates and starts the grpc server.
      Throws:
      IOException - If the server is unable to bind the port.
    • stopAndReleaseGrpcServer

      protected void stopAndReleaseGrpcServer()
      Initiates an orderly shutdown of the grpc server and releases the references to the server. This call waits for the server to be completely shut down.