Class RequestLimitingHandler

  • All Implemented Interfaces:
    HttpHandler

    public final class RequestLimitingHandler
    extends Object
    implements HttpHandler
    A handler which limits the maximum number of concurrent requests. Requests beyond the limit will block until the previous request is complete.
    Author:
    David M. Lloyd
    • Constructor Detail

      • RequestLimitingHandler

        public RequestLimitingHandler​(int maximumConcurrentRequests,
                                      HttpHandler nextHandler)
        Construct a new instance. The maximum number of concurrent requests must be at least one. The next handler must not be null.
        Parameters:
        maximumConcurrentRequests - the maximum concurrent requests
        nextHandler - the next handler
      • RequestLimitingHandler

        public RequestLimitingHandler​(int maximumConcurrentRequests,
                                      int queueSize,
                                      HttpHandler nextHandler)
        Construct a new instance. The maximum number of concurrent requests must be at least one. The next handler must not be null.
        Parameters:
        maximumConcurrentRequests - the maximum concurrent requests
        queueSize - the maximum number of requests to queue
        nextHandler - the next handler
      • RequestLimitingHandler

        public RequestLimitingHandler​(RequestLimit requestLimit,
                                      HttpHandler nextHandler)
        Construct a new instance. This version takes a RequestLimit directly which may be shared with other handlers.
        Parameters:
        requestLimit - the request limit information.
        nextHandler - the next handler