Class GrpcServerLifecycle
java.lang.Object
net.devh.boot.grpc.server.serverfactory.GrpcServerLifecycle
- All Implemented Interfaces:
Lifecycle
,Phased
,SmartLifecycle
Lifecycle bean that automatically starts and stops the grpc server.
-
Field Summary
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
ConstructorsConstructorDescriptionGrpcServerLifecycle
(GrpcServerFactory factory, Duration shutdownGracePeriod, ApplicationEventPublisher eventPublisher) Creates a new GrpcServerLifecycle -
Method Summary
-
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() -
stop
public void stop() -
stop
- Specified by:
stop
in interfaceSmartLifecycle
-
isRunning
public boolean isRunning() -
getPhase
public int getPhase()- Specified by:
getPhase
in interfacePhased
- Specified by:
getPhase
in interfaceSmartLifecycle
-
isAutoStartup
public boolean isAutoStartup()- Specified by:
isAutoStartup
in interfaceSmartLifecycle
-
createAndStartGrpcServer
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.
-