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 ClientPeerRejectionPolicyDefault rejection policy for peer responses. -
Method Summary
Modifier and TypeMethodDescriptionstatic ClientPeerRejectionPolicyofPassthrough(Predicate<HttpResponseMetaData> predicate) Evaluate responses with the givenPredicateas capacity related rejections, that will affect theCapacityLimiterin use, but allow the original response from the upstream to pass-through this filter.static ClientPeerRejectionPolicyofRejection(Predicate<HttpResponseMetaData> rejectionPredicate) Evaluate responses with the givenPredicateas capacity related rejections, that will affect theCapacityLimiterin use, and translate that to en exception.static ClientPeerRejectionPolicyofRejectionWithRetries(Predicate<HttpResponseMetaData> rejectionPredicate, Function<HttpResponseMetaData, Duration> delayProvider) Evaluate responses with the givenPredicateas capacity related rejections, that will affect theCapacityLimiterin 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_REQUESTSHttpResponseStatus.BAD_GATEWAYHttpResponseStatus.SERVICE_UNAVAILABLE
If a
CircuitBreakeris used consider adjusting this predicate to avoid consideringHttpResponseStatus.SERVICE_UNAVAILABLEas 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_REQUESTSHttpResponseStatus.BAD_GATEWAYHttpResponseStatus.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 givenPredicateas capacity related rejections, that will affect theCapacityLimiterin use, but allow the original response from the upstream to pass-through this filter.- Parameters:
predicate- ThePredicateto evaluate responses. Returningtruefrom thisPredicatesignifies 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 givenPredicateas capacity related rejections, that will affect theCapacityLimiterin use, and translate that to en exception.- Parameters:
rejectionPredicate- ThePredicateto evaluate responses. Returningtruefrom thisPredicatesignifies 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 givenPredicateas capacity related rejections, that will affect theCapacityLimiterin use, and translate that to an exception that contains "delay" information useful when retrying it through a retrying filter.- Parameters:
rejectionPredicate- ThePredicateto evaluate responses. Returningtruefrom thisPredicatesignifies that the response was capacity related rejection from the peer.delayProvider- ADurationprovider for delay purposes when retrying.- Returns:
- A
ClientPeerRejectionPolicy.
-