Class ClientPeerRejectionPolicy
java.lang.Object
io.servicetalk.traffic.resilience.http.ClientPeerRejectionPolicy
Policy for peer capacity rejections that allows customization of behavior (retries or pass-through).
This is meant to be used as a policy on the
TrafficResilienceHttpServiceFilter
.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Predicate<HttpResponseMetaData>
Default rejection observer for dropped requests from an external sourced.static final ClientPeerRejectionPolicy
Default rejection policy for peer responses. -
Method Summary
Modifier and TypeMethodDescriptionstatic ClientPeerRejectionPolicy
ofPassthrough
(Predicate<HttpResponseMetaData> predicate) Evaluate responses with the givenPredicate
as capacity related rejections, that will affect theCapacityLimiter
in use, but allow the original response from the upstream to pass-through this filter.static ClientPeerRejectionPolicy
ofRejection
(Predicate<HttpResponseMetaData> rejectionPredicate) Evaluate responses with the givenPredicate
as capacity related rejections, that will affect theCapacityLimiter
in use, and translate that to en exception.static ClientPeerRejectionPolicy
ofRejectionWithRetries
(Predicate<HttpResponseMetaData> rejectionPredicate, Function<HttpResponseMetaData, Duration> delayProvider) Evaluate responses with the givenPredicate
as capacity related rejections, that will affect theCapacityLimiter
in use, and translate that to an exception that contains "delay" information useful when retrying it through a retrying filter.
-
Field Details
-
DEFAULT_CAPACITY_REJECTION_PREDICATE
Default rejection observer for dropped requests from an external sourced. see.TrafficResilienceHttpClientFilter.Builder.rejectionPolicy(ClientPeerRejectionPolicy)
.The default predicate matches the following HTTP response codes:
HttpResponseStatus.TOO_MANY_REQUESTS
HttpResponseStatus.BAD_GATEWAY
HttpResponseStatus.SERVICE_UNAVAILABLE
If a
CircuitBreaker
is used consider adjusting this predicate to avoid consideringHttpResponseStatus.SERVICE_UNAVAILABLE
as a capacity issue. -
DEFAULT_PEER_REJECTION_POLICY
Default rejection policy for peer responses. The following responses will be considered rejections, and exercise the rejection policy;HttpResponseStatus.TOO_MANY_REQUESTS
HttpResponseStatus.BAD_GATEWAY
HttpResponseStatus.SERVICE_UNAVAILABLE
The default behavior upon such a case, is to issue a retryable exception with no pre-set offset delay (outside the default backoff policy of configured retry filter).
-
-
Method Details
-
ofPassthrough
Evaluate responses with the givenPredicate
as capacity related rejections, that will affect theCapacityLimiter
in use, but allow the original response from the upstream to pass-through this filter.- Parameters:
predicate
- ThePredicate
to evaluate responses. Returningtrue
from thisPredicate
signifies that the response was capacity related rejection from the peer.- Returns:
- A
ClientPeerRejectionPolicy
.
-
ofRejection
public static ClientPeerRejectionPolicy ofRejection(Predicate<HttpResponseMetaData> rejectionPredicate) Evaluate responses with the givenPredicate
as capacity related rejections, that will affect theCapacityLimiter
in use, and translate that to en exception.- Parameters:
rejectionPredicate
- ThePredicate
to evaluate responses. Returningtrue
from thisPredicate
signifies that the response was capacity related rejection from the peer.- Returns:
- A
ClientPeerRejectionPolicy
.
-
ofRejectionWithRetries
public static ClientPeerRejectionPolicy ofRejectionWithRetries(Predicate<HttpResponseMetaData> rejectionPredicate, Function<HttpResponseMetaData, Duration> delayProvider) Evaluate responses with the givenPredicate
as capacity related rejections, that will affect theCapacityLimiter
in use, and translate that to an exception that contains "delay" information useful when retrying it through a retrying filter.- Parameters:
rejectionPredicate
- ThePredicate
to evaluate responses. Returningtrue
from thisPredicate
signifies that the response was capacity related rejection from the peer.delayProvider
- ADuration
provider for delay purposes when retrying.- Returns:
- A
ClientPeerRejectionPolicy
.
-