-
Notifications
You must be signed in to change notification settings - Fork 969
Open
Labels
Description
Server and ClientFactory currently calls EventLoopGroup.shutdownGracefully() to terminate Netty EventLoopGroups when they stop or close. shutdownGracefully() incurs 2-3 second delay and it can make the applications suffer when it needs to start and stop frequently.
It'd be nice if Armeria provides a user to customize the graceful shutdown delay of EventLoopGroups, like it does for Server requests, so that they can minimize the amount of time required for tearing down a Server or a ClientFactory.
We could, for example, allow a user to specify a config instead of boolean shutdownOnStop in ServerBuilder and ClientFactoryBuilder methods, e.g.
public class GracefulShutdownSpec {
// External resource managed by the caller - don't shut down
public static GracefulShutdownSpec ofExternal() { ... }
// Don't shut down gracefully - shut down immediately
public static GracefulShutdownSpec ofImmediate() { ... }
// Shut down gracefully
public static GracefulShutdownSpec of(quiet period, hard timeout) { ... }
}
Server
.builder()
.workerGroup(..., GracefulShutdownSpec.of...)
// Could be reused for the existing graceful shutdown settings
// Note: `ofExternal` is not allowed here.
.gracefulShutdownTimeout(GracefulShutdownSpec.of...)
...novoj