Package com.linecorp.armeria.common
Interface SuccessFunction
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A function that determines whether a
Client and Service handled a request successfully
or not.
This function can be used by the decorators like the following to determine
whether the request was handled successfully or not:
Example:
ServerBuilder sb = Server
.builder()
.successFunction((ctx, req) -> req.responseHeaders().status().code() == 200 ||
req.responseHeaders().status().code() == 404)
.decorator(MetricCollectingService.newDecorator(MeterIdPrefixFunction.ofDefault("myServer")))
.decorator(LoggingService.newDecorator()));
WebClient client = WebClient
.builder(uri)
.successFunction((ctx, req) -> req.responseHeaders().status().code() == 200 ||
req.responseHeaders().status().code() == 404)
.decorator(MetricCollectingClient.newDecorator(MeterIdPrefixFunction.ofDefault("myClient")))
.decorator(LoggingClient.newDecorator()))
.build();
-
Method Summary
Modifier and TypeMethodDescriptionstatic SuccessFunctionalways()Returns aSuccessFunctionthat will always returntrue.booleanisSuccess(RequestContext ctx, RequestLog log) Returnstrueif the request was handled successfully.static SuccessFunctionnever()Returns aSuccessFunctionthat will always returnfalse.static SuccessFunctionReturns the default success classification function which checksRequestLog.responseCause()is null, 100 <=HttpStatus< 400 andRpcResponse.isCompletedExceptionally()==false.
-
Method Details
-
never
Returns aSuccessFunctionthat will always returnfalse. -
always
Returns aSuccessFunctionthat will always returntrue. -
ofDefault
Returns the default success classification function which checksRequestLog.responseCause()is null, 100 <=HttpStatus< 400 andRpcResponse.isCompletedExceptionally()==false. -
isSuccess
Returnstrueif the request was handled successfully.
-