Class ThrottlingHttpService
- java.lang.Object
-
- com.linecorp.armeria.server.DecoratingService<I,O,I,O>
-
- com.linecorp.armeria.server.SimpleDecoratingService<I,O>
-
- com.linecorp.armeria.server.throttling.ThrottlingService<HttpRequest,HttpResponse>
-
- com.linecorp.armeria.server.throttling.ThrottlingHttpService
-
- All Implemented Interfaces:
Service<HttpRequest,HttpResponse>
public class ThrottlingHttpService extends ThrottlingService<HttpRequest,HttpResponse>
Decorates a HTTPService
to throttle incoming requests.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ThrottlingHttpService(Service<HttpRequest,HttpResponse> delegate, ThrottlingStrategy<HttpRequest> strategy)
Creates a new instance that decorates the specifiedService
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Function<Service<HttpRequest,HttpResponse>,ThrottlingHttpService>
newDecorator(ThrottlingStrategy<HttpRequest> strategy)
Creates a new decorator using the specifiedThrottlingStrategy
instance.protected HttpResponse
onFailure(ServiceRequestContext ctx, HttpRequest req, Throwable cause)
Invoked whenreq
is throttled.-
Methods inherited from class com.linecorp.armeria.server.throttling.ThrottlingService
onSuccess, serve
-
Methods inherited from class com.linecorp.armeria.server.DecoratingService
as, delegate, serviceAdded, shouldCachePath, toString
-
-
-
-
Constructor Detail
-
ThrottlingHttpService
protected ThrottlingHttpService(Service<HttpRequest,HttpResponse> delegate, ThrottlingStrategy<HttpRequest> strategy)
Creates a new instance that decorates the specifiedService
.
-
-
Method Detail
-
newDecorator
public static Function<Service<HttpRequest,HttpResponse>,ThrottlingHttpService> newDecorator(ThrottlingStrategy<HttpRequest> strategy)
Creates a new decorator using the specifiedThrottlingStrategy
instance.- Parameters:
strategy
- TheThrottlingStrategy
instance to be used
-
onFailure
protected HttpResponse onFailure(ServiceRequestContext ctx, HttpRequest req, @Nullable Throwable cause) throws Exception
Invoked whenreq
is throttled. By default, this method responds with theHttpStatus.SERVICE_UNAVAILABLE
status.- Specified by:
onFailure
in classThrottlingService<HttpRequest,HttpResponse>
- Throws:
Exception
-
-