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 Type Method Description static 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)
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
-
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
public static Function<? super HttpClient,ConcurrencyLimitingClient> newDecorator(int maxConcurrency, long timeout, TimeUnit unit)Creates a newHttpClient
decorator that limits the concurrent number of active HTTP requests. -
newDeferredResponse
protected HttpResponse newDeferredResponse(ClientRequestContext ctx, CompletionStage<HttpResponse> resFuture) throws ExceptionDescription 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.from(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
-