Class ListenerOptions

java.lang.Object
com.jsgalactic.axiom.lifecycle.ListenerOptions

public final class ListenerOptions extends Object
Transport limits and timeouts of one HTTP listener, passed to Application.listen(java.net.InetSocketAddress, ListenerOptions). Every setting has a secure bounded default, so defaults() suits most deployments, and a documented valid range that the builder enforces when a value is set. Instances are immutable and may be shared by several listeners; each listener applies its own copy of the limits to its own connections.

The settings are interpreted by the installed transport. They bound what a client can make a listener hold or wait for; they do not change request semantics. Application-level limits stay on the application: the request body limit, the execution deadline and admission. How the connection cap relates to admission is described at ListenerOptions.Builder.maxConnections(int).

Durations use the range 1 millisecond to 1 day (the shutdown grace period also allows zero).

  • Field Details

  • Method Details

    • defaults

      public static ListenerOptions defaults()
      Returns the default options.
      Returns:
      shared immutable defaults, each setting at the default given on its builder method
    • builder

      public static ListenerOptions.Builder builder()
      Starts a builder with every setting at its default.
      Returns:
      a new builder
    • toBuilder

      public ListenerOptions.Builder toBuilder()
      Starts a builder holding these options' values.
      Returns:
      a new builder
    • shutdownGrace

      public Duration shutdownGrace()
      Returns:
      how long closing the listener lets in-flight exchanges finish before interrupting them
    • idleTimeout

      public Duration idleTimeout()
      Returns:
      network inactivity after which a connection closes
    • headTimeout

      public Duration headTimeout()
      Returns:
      bound from a request's first byte until its head is complete
    • responseTimeout

      public Duration responseTimeout()
      Returns:
      bound on writing one response to the socket
    • lingerTimeout

      public Duration lingerTimeout()
      Returns:
      total bound on reading and discarding input after the last response
    • lingerQuietTimeout

      public Duration lingerQuietTimeout()
      Returns:
      silence after which lingering ends
    • shutdownLingerTimeout

      public Duration shutdownLingerTimeout()
      Returns:
      total linger bound once the listener is closing
    • handshakeTimeout

      public Duration handshakeTimeout()
      Returns:
      bound on the TLS handshake of a new connection; applies only when tls() is present
    • tls

      public Optional<TlsOptions> tls()
      Returns:
      the TLS settings; empty when the listener serves plain HTTP
    • http2Enabled

      public boolean http2Enabled()
      Returns:
      whether the listener accepts HTTP/2: negotiated with ALPN when TLS is configured, otherwise by HTTP/2 prior knowledge on a cleartext connection
    • compressionEnabled

      public boolean compressionEnabled()
      Returns:
      whether the listener decodes compressed request bodies and compresses eligible response bodies; false unless the builder opted in
    • compressionLevel

      public int compressionLevel()
      Returns the deflater level used for compressed responses. Request decompression always uses the sender's level, so this setting affects only bytes this listener produces.
      Returns:
      level from 1 (fastest) to 9 (smallest); the default is 6
    • maxDiscardedInput

      public int maxDiscardedInput()
      Returns:
      bytes discarded unread after an error or last response before the connection is closed
    • maxConnections

      public int maxConnections()
      Returns:
      open connections per listener
    • maxLingeringConnections

      public int maxLingeringConnections()
      Returns:
      connections that may linger without holding a regular connection slot
    • maxPipelinedRequests

      public int maxPipelinedRequests()
      Returns:
      outstanding requests per connection, including the running one
    • maxInFlightBodyBytes

      public long maxInFlightBodyBytes()
      Returns:
      request body bytes this listener holds at once, across all its connections
    • maxRequestLine

      public int maxRequestLine()
      Returns:
      longest request line in bytes
    • maxHeaderBytes

      public int maxHeaderBytes()
      Returns:
      largest header section in bytes
    • ioThreads

      public int ioThreads()
      Returns:
      number of I/O threads per listener
    • transport

      public TransportKind transport()
      Returns:
      the requested I/O mechanism; TransportKind.AUTO unless set
    • rejectionObserver

      public Optional<RejectionObserver> rejectionObserver()
      Returns:
      the observer of the listener's own error responses, if one was set
    • name

      public String name()
      Returns:
      the listener's name, the value of the listener metric tag
    • toString

      public String toString()
      Overrides:
      toString in class Object