public class ConcurrencyLimitingClient extends AbstractConcurrencyLimitingClient<HttpRequest,HttpResponse> implements HttpClient
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();
| Modifier and Type | Method and Description |
|---|---|
static Function<? super HttpClient,ConcurrencyLimitingClient> |
newDecorator(int maxConcurrency)
Creates a new
HttpClient decorator that limits the concurrent number of active HTTP requests. |
static Function<? super HttpClient,ConcurrencyLimitingClient> |
newDecorator(int maxConcurrency,
long timeout,
TimeUnit unit)
Creates a new
HttpClient decorator that limits the concurrent number of active HTTP requests. |
protected HttpResponse |
newDeferredResponse(ClientRequestContext ctx,
CompletionStage<HttpResponse> resFuture)
Implement this method to return a new
Response which delegates to the Response
the specified CompletionStage is completed with. |
execute, numActiveRequestsas, delegate, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitexecutepublic static Function<? super HttpClient,ConcurrencyLimitingClient> newDecorator(int maxConcurrency)
HttpClient decorator that limits the concurrent number of active HTTP requests.public static Function<? super HttpClient,ConcurrencyLimitingClient> newDecorator(int maxConcurrency, long timeout, TimeUnit unit)
HttpClient decorator that limits the concurrent number of active HTTP requests.protected HttpResponse newDeferredResponse(ClientRequestContext ctx, CompletionStage<HttpResponse> resFuture) throws Exception
AbstractConcurrencyLimitingClientResponse which delegates to the Response
the specified CompletionStage is completed with. For example, you could use
HttpResponse.from(CompletionStage, EventExecutor):
protected HttpResponse newDeferredResponse(
ClientRequestContext ctx, CompletionStage<HttpResponse> resFuture) {
return HttpResponse.from(resFuture, ctx.eventLoop());
}
newDeferredResponse in class AbstractConcurrencyLimitingClient<HttpRequest,HttpResponse>ExceptionCopyright © 2020 LeanCloud. All rights reserved.