Interface ServerListenContext

All Known Subinterfaces:
GrpcServerContext, HttpServerContext, ServerContext
All Known Implementing Classes:
DelegatingHttpServiceContext, HttpServiceContext, NettyServerContext

public interface ServerListenContext
Context for controlling listen behavior.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    acceptConnections(boolean accept)
    Toggles the server's ability to accept new connections.
  • Method Details

    • acceptConnections

      void acceptConnections(boolean accept)
      Toggles the server's ability to accept new connections.

      Passing a false value will signal the server to stop accepting new connections. It won't affect any other interactions to currently open connections (i.e., reads / writes).

      Depending on the transport, connections may still get ESTABLISHED, see backlog or OS wide settings:

      For instance, in case of TCP the 3-way handshake may finish, and the connection will await in the accept queue to be accepted. If the accept queue is full, connection SYNs will await in the SYN backlog (in the case of linux). This can be tuned: tcp_max_syn_backlog These additional parameters may affect the behavior of new flows when the service is not accepting.

      Depending on how long this stays in the false state, it may affect other timeouts (i.e., connect-timeout or idleness) on the peer-side and/or the other flows to the peer (i.e., proxies).

      Considerations:

      • Upon resumption, accept == true, backlogged connections will be processed first, which may be inactive by that time.
      • The effect of toggling connection acceptance may be lazy evaluated (implementation detail), meaning that connections may still go through even after setting this to false.
      Parameters:
      accept - Toggles the server's accepting connection ability.