Class AbstractConcurrencyLimitingClient<I extends Request,​O extends Response>

java.lang.Object
com.linecorp.armeria.common.util.AbstractUnwrappable<Client<T_I,​T_O>>
com.linecorp.armeria.client.DecoratingClient<I,​O,​I,​O>
com.linecorp.armeria.client.SimpleDecoratingClient<I,​O>
com.linecorp.armeria.client.limit.AbstractConcurrencyLimitingClient<I,​O>
Type Parameters:
I - the Request type
O - the Response type
All Implemented Interfaces:
Client<I,​O>, Unwrappable
Direct Known Subclasses:
ConcurrencyLimitingClient

public abstract class AbstractConcurrencyLimitingClient<I extends Request,​O extends Response>
extends SimpleDecoratingClient<I,​O>
An abstract Client decorator that limits the concurrent number of active requests.

numActiveRequests() increases when Client.execute(ClientRequestContext, Request) is invoked and decreases when the Response returned by the Client.execute(ClientRequestContext, Request) is closed. When numActiveRequests() reaches at the configured maxConcurrency the Requests are deferred until the currently active Requests are completed.

  • Constructor Details

    • AbstractConcurrencyLimitingClient

      protected AbstractConcurrencyLimitingClient​(Client<I,​O> delegate, int maxConcurrency)
      Creates a new instance that decorates the specified delegate to limit the concurrent number of active requests to maxConcurrency, with the default timeout of 10000L milliseconds.
      Parameters:
      delegate - the delegate Client
      maxConcurrency - the maximum number of concurrent active requests. 0 to disable the limit.
    • AbstractConcurrencyLimitingClient

      protected AbstractConcurrencyLimitingClient​(Client<I,​O> delegate, int maxConcurrency, long timeout, TimeUnit unit)
      Creates a new instance that decorates the specified delegate to limit the concurrent number of active requests to maxConcurrency.
      Parameters:
      delegate - the delegate Client
      maxConcurrency - the maximum number of concurrent active requests. 0 to disable the limit.
      timeout - the amount of time until this decorator fails the request if the request was not delegated to the delegate before then
  • Method Details