Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to terminate unfinished requests after graceful shutdown #5941

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Commits on Oct 16, 2024

  1. Provide a way to terminate unfinished requests after graceful shutdown

    Motivation:
    
    Unfinished requests even after graceful shutdown period are forcivily
    closed with `ClosedSessionException`. As `ClosedSessionException`
    indicates that the connection was unexpectedly disconnected,
    `ClosedSessionException` is not suitable for graceful shutdown.
    
    In this PR, I propose to add `ShuttingDownException` to terminate
    unfinished requests when a server stops.
    
    Modifications:
    
    - Introduce `GracefulShutdown` to customize graceful shutdown behavior.
      - Users can specify a error function to create an exception to
        unfinished terminate requests.
    - Fixed `HttpServerHandler` to send error responses using the error
      function of `GracefulShutdown`
    - Fixed `Server` to send error respones first and then close the
      connnections.
    - Deprecation) `ServerConfig.gracefulShutdownQuietPeriod()` and
      `ServerConfig.gracefulShutdownTimeout()` have been deprecated in favor
      of `ServerConfig.gracefulShutdown()`.
    
    Result:
    
    You can now use `GracefulShutdown` to terminate unfinished requests when
    a server stops.
    ```java
    GracefulShutdown gracefulShutdown =
      GracefulShutdown
        .builder()
        .quietPeriod(Duration.ofSeconds(10))
        .timeout(Duration.ofSeconds(15))
        .shutdownErrorFunction((ctx, req) -> {
            return new ServerStopException();
        })
        .build();
    
    Server
      .builder()
      .gracefulShutdown(gracefulShutdown);
    ```
    ikhoon committed Oct 16, 2024
    Configuration menu
    Copy the full SHA
    b5949a4 View commit details
    Browse the repository at this point in the history
  2. lint

    ikhoon committed Oct 16, 2024
    Configuration menu
    Copy the full SHA
    7277f60 View commit details
    Browse the repository at this point in the history

Commits on Oct 18, 2024

  1. Configuration menu
    Copy the full SHA
    9d83337 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    685f93d View commit details
    Browse the repository at this point in the history

Commits on Oct 23, 2024

  1. lint

    ikhoon committed Oct 23, 2024
    Configuration menu
    Copy the full SHA
    227b6b4 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0a40aa8 View commit details
    Browse the repository at this point in the history

Commits on Nov 11, 2024

  1. execute in event loops

    ikhoon committed Nov 11, 2024
    Configuration menu
    Copy the full SHA
    538deba View commit details
    Browse the repository at this point in the history