Interface Configurable<T extends Configurable<T>>

Type Parameters:
T - The type of configurable for casting.
All Known Implementing Classes:
HTTPServer, HTTPServerConfiguration

public interface Configurable<T extends Configurable<T>>
An interface that identifies something that is configurable. Mainly, this allows the HTTPServer to be configured or to be passed a configuration.
  • Method Details

    • configuration

      HTTPServerConfiguration configuration()
      Returns:
      The configuration object.
    • withBaseDir

      default T withBaseDir(Path baseDir)
      Sets the base directory for this server. This is passed to the HTTPContext, which is available from this class. This defaults to the current working directory of the process.
      Parameters:
      baseDir - The base dir.
      Returns:
      This.
    • withClientTimeout

      default T withClientTimeout(Duration duration)
      Sets the duration that the server will allow client connections to remain open. This includes Keep-Alive as well as read timeout. Defaults to 20 seconds.
      Parameters:
      duration - The duration.
      Returns:
      This.
    • withCompressByDefault

      default T withCompressByDefault(boolean compressByDefault)
      Sets the default compression behavior for the HTTP response. This behavior can be optionally set per response. See HTTPResponse.setCompress(boolean). Defaults to true.
      Parameters:
      compressByDefault - true if you want to compress by default, or false to not compress by default.
      Returns:
      This.
    • withContextPath

      default T withContextPath(String contextPath)
      Sets the prefix of the URIs that this server handles. Technically, the server will accept all inbound connections, but if a context path is set, it can assist the application with building URIs (in HTML for example). This value will be accessible via the HTTPRequest.getContextPath() method.
      Parameters:
      contextPath - The context path for the server.
      Returns:
      This.
    • withExpectValidator

      default T withExpectValidator(ExpectValidator validator)
      Sets an ExpectValidator that is used if a client sends the server a Expect: 100-continue header.
      Parameters:
      validator - The validator.
      Returns:
      This.
    • withHandler

      default T withHandler(HTTPHandler handler)
      Sets the handler that will process the requests.
      Parameters:
      handler - The handler that processes the requests.
      Returns:
      This.
    • withInstrumenter

      default T withInstrumenter(Instrumenter instrumenter)
      Sets an instrumenter that the server will notify when events and conditions happen.
      Parameters:
      instrumenter - The instrumenter.
      Returns:
      This.
    • withListener

      default T withListener(HTTPListenerConfiguration listener)
      Adds a listener configuration for the server. This will listen on the address and port of the configuration but will share the thread pool of the server.
      Parameters:
      listener - The listener.
      Returns:
      This.
    • withLoggerFactory

      default T withLoggerFactory(LoggerFactory loggerFactory)
      Sets the logger factory that all the HTTP server classes use to retrieve specific loggers. Defaults to the SystemOutLoggerFactory.
      Parameters:
      loggerFactory - The factory.
      Returns:
      This.
    • withMaxOutputBufferQueueLength

      default T withMaxOutputBufferQueueLength(int outputBufferQueueLength)
      Sets the maximum length of the output buffer queue. Defaults to 128.

      This parameter will affect the runtime memory requirement of the server. This can be calculated by multiplying this value by values returned from HTTPServerConfiguration.getResponseBufferSize() and HTTPServerConfiguration.getNumberOfWorkerThreads().

      Parameters:
      outputBufferQueueLength - The length of the output buffer queue.
      Returns:
      This.
    • withMaxPreambleLength

      default T withMaxPreambleLength(int maxLength)
      Sets the max preamble length (the start-line and headers constitute the head). Defaults to 64k
      Parameters:
      maxLength - The max preamble length.
      Returns:
      This.
    • withMinimumReadThroughput

      default T withMinimumReadThroughput(long bytesPerSecond)
      This configures the minimum number of bytes per second that a client must send a request to the server before the server closes the connection.
      Parameters:
      bytesPerSecond - The bytes per second throughput.
      Returns:
      This.
    • withMinimumWriteThroughput

      default T withMinimumWriteThroughput(long bytesPerSecond)
      This configures the minimum number of bytes per second that a client must read the response from the server before the server closes the connection.
      Parameters:
      bytesPerSecond - The bytes per second throughput.
      Returns:
      This.
    • withMultipartBufferSize

      default T withMultipartBufferSize(int multipartBufferSize)
      Sets the size of the buffer that is used to process the multipart request body. This defaults to 16k.
      Parameters:
      multipartBufferSize - The size of the buffer.
      Returns:
      This.
    • withNumberOfWorkerThreads

      default T withNumberOfWorkerThreads(int numberOfWorkerThreads)
      Sets the number of worker threads that will handle requests coming into the HTTP server. Defaults to 40.

      This parameter will affect the runtime memory requirement of the server. This can be calculated by multiplying this value by the returned from HTTPServerConfiguration.getResponseBufferSize() and HTTPServerConfiguration.getMaxOutputBufferQueueLength().

      Parameters:
      numberOfWorkerThreads - The number of worker threads.
      Returns:
      This.
    • withPreambleBufferSize

      default T withPreambleBufferSize(int size)
      Sets the size of the preamble buffer (that is the buffer that reads the start-line and headers). Defaults to 4096.
      Parameters:
      size - The buffer size.
      Returns:
      This.
    • withReadThroughputCalculationDelayDuration

      default T withReadThroughputCalculationDelayDuration(Duration duration)
      This configures the duration of the initial delay before calculating and enforcing the minimum read throughput. Defaults to 5 seconds.

      This accounts for some warm up period, and exempts short-lived connections that may have smaller payloads that are more difficult to calculate a reasonable minimum read throughput.

      Parameters:
      duration - The duration to delay the enforcement of the minimum read throughput.
      Returns:
      This.
    • withRequestBufferSize

      default T withRequestBufferSize(int requestBufferSize)
      Sets the size of the buffer that is used to process the HTTP request. This defaults to 16k.
      Parameters:
      requestBufferSize - The size of the buffer.
      Returns:
      This.
    • withResponseBufferSize

      default T withResponseBufferSize(int responseBufferSize)
      Sets the size of the buffer that is used to process the HTTP response. This defaults to 16k.

      This parameter will affect the runtime memory requirement of the server. This can be calculated by multiplying this value by the returned from HTTPServerConfiguration.getNumberOfWorkerThreads() and HTTPServerConfiguration.getMaxOutputBufferQueueLength().

      Parameters:
      responseBufferSize - The size of the buffer.
      Returns:
      This.
    • withShutdownDuration

      default T withShutdownDuration(Duration duration)
      Sets the duration the server will wait for running requests to be completed. Defaults to 10 seconds.
      Parameters:
      duration - The duration the server will wait for all running request processing threads to complete their work.
      Returns:
      This.
    • withWriteThroughputCalculationDelayDuration

      default T withWriteThroughputCalculationDelayDuration(Duration duration)
      This configures the duration of the initial delay before calculating and enforcing the minimum write throughput. Defaults to 5 seconds.

      This accounts for some warm up period, and exempts short-lived connections that may have smaller payloads that are more difficult to calculate a reasonable minimum write throughput.

      Parameters:
      duration - The duration to delay the enforcement of the minimum write throughput.
      Returns:
      This.