Class ConcurrencyLimitingClient
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<HttpRequest,HttpResponse>
com.linecorp.armeria.client.limit.ConcurrencyLimitingClient
- All Implemented Interfaces:
Client<HttpRequest,
,HttpResponse> HttpClient
,Unwrappable
public final class ConcurrencyLimitingClient
extends AbstractConcurrencyLimitingClient<HttpRequest,HttpResponse>
implements HttpClient
An
HttpClient
decorator that limits the concurrent number of active HTTP requests.
For example:
WebClientBuilder builder = WebClient.builder(...);
builder.decorator(ConcurrencyLimitingClient.newDecorator(16));
WebClient client = builder.build();
-
Method Summary
Modifier and TypeMethodDescriptionstatic Function<? super HttpClient,
ConcurrencyLimitingClient> newDecorator
(int maxConcurrency) Creates a newHttpClient
decorator that limits the concurrent number of active HTTP requests.static Function<? super HttpClient,
ConcurrencyLimitingClient> newDecorator
(int maxConcurrency, long timeout, TimeUnit unit) Deprecated.static Function<? super HttpClient,
ConcurrencyLimitingClient> newDecorator
(ConcurrencyLimit concurrencyLimit) Creates a newHttpClient
decorator that limits the concurrent number of active HTTP requests.static Function<? super HttpClient,
ConcurrencyLimitingClient> newDecorator
(IntSupplier maxConcurrency) Creates a newHttpClient
decorator that limits the concurrent number of active HTTP requests.protected HttpResponse
newDeferredResponse
(ClientRequestContext ctx, CompletionStage<HttpResponse> resFuture) Implement this method to return a newResponse
which delegates to theResponse
the specifiedCompletionStage
is completed with.Methods inherited from class com.linecorp.armeria.client.limit.AbstractConcurrencyLimitingClient
execute, numActiveRequests
Methods inherited from class com.linecorp.armeria.common.util.AbstractUnwrappable
as, toString, unwrap, unwrapAll
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.linecorp.armeria.client.HttpClient
execute
Methods inherited from interface com.linecorp.armeria.common.util.Unwrappable
equalsIgnoreWrapper, unwrapAll
-
Method Details
-
newDecorator
public static Function<? super HttpClient,ConcurrencyLimitingClient> newDecorator(int maxConcurrency) Creates a newHttpClient
decorator that limits the concurrent number of active HTTP requests. -
newDecorator
@Deprecated public static Function<? super HttpClient,ConcurrencyLimitingClient> newDecorator(int maxConcurrency, long timeout, TimeUnit unit) Deprecated.UsenewDecorator(ConcurrencyLimit)
with the limit created viaConcurrencyLimit.builder(int)
Creates a newHttpClient
decorator that limits the concurrent number of active HTTP requests. -
newDecorator
public static Function<? super HttpClient,ConcurrencyLimitingClient> newDecorator(IntSupplier maxConcurrency) Creates a newHttpClient
decorator that limits the concurrent number of active HTTP requests. -
newDecorator
@UnstableApi public static Function<? super HttpClient,ConcurrencyLimitingClient> newDecorator(ConcurrencyLimit concurrencyLimit) Creates a newHttpClient
decorator that limits the concurrent number of active HTTP requests. -
newDeferredResponse
protected HttpResponse newDeferredResponse(ClientRequestContext ctx, CompletionStage<HttpResponse> resFuture) throws Exception Description copied from class:AbstractConcurrencyLimitingClient
Implement this method to return a newResponse
which delegates to theResponse
the specifiedCompletionStage
is completed with. For example, you could useHttpResponse.of(CompletionStage, EventExecutor)
:protected HttpResponse newDeferredResponse( ClientRequestContext ctx, CompletionStage<HttpResponse> resFuture) { return HttpResponse.from(resFuture, ctx.eventLoop()); }
- Specified by:
newDeferredResponse
in classAbstractConcurrencyLimitingClient<HttpRequest,
HttpResponse> - Throws:
Exception
-
newDecorator(ConcurrencyLimit)
with the limit created viaConcurrencyLimit.builder(int)