public abstract class AbstractThrottlingService<I extends Request,O extends Response> extends SimpleDecoratingService<I,O>
Service to throttle incoming requests.| Modifier | Constructor and Description |
|---|---|
protected |
AbstractThrottlingService(Service<I,O> delegate,
ThrottlingStrategy<I> strategy,
Function<CompletionStage<? extends O>,O> responseConverter)
Creates a new instance that decorates the specified
Service. |
| Modifier and Type | Method and Description |
|---|---|
protected abstract O |
onFailure(ServiceRequestContext ctx,
I req,
Throwable cause)
Invoked when
req is throttled. |
protected O |
onSuccess(ServiceRequestContext ctx,
I req)
Invoked when
req is not throttled. |
O |
serve(ServiceRequestContext ctx,
I req)
Serves an incoming
Request. |
serviceAdded, shouldCachePathas, delegate, toStringprotected AbstractThrottlingService(Service<I,O> delegate, ThrottlingStrategy<I> strategy, Function<CompletionStage<? extends O>,O> responseConverter)
Service.protected O onSuccess(ServiceRequestContext ctx, I req) throws Exception
req is not throttled. By default, this method delegates the specified req to
the AbstractUnwrappable.delegate() of this service.Exceptionprotected abstract O onFailure(ServiceRequestContext ctx, I req, Throwable cause) throws Exception
req is throttled. By default, this method responds with the
HttpStatus.SERVICE_UNAVAILABLE status.ExceptionCopyright © 2020 LeanCloud. All rights reserved.