Closed ikhoon closed 1 month ago
It seems like OutlierDetectingRule is used alongside OutlierDetector, and both are retrieved and created from this OutlierDetection. What do you think of adding OutlierDetectingRule to OutlierDetector instead?
They are used together but the role of OutlierDetector
and OutlierDetectingRule
is different. OutlierDetector
is designed as a utility. It may be used alone. So I didn't want to force users who only need OutlierDetector
to implement OutlierDetectingRule
.
OutlierDetector is designed as a utility. It may be used alone.
Haven't thought about this case. Then, I'm fine with the current design. 👍
Motivation:
Currently, there is no extension point to detect errors for specific connections and terminate connections that are unhealthy.
Related: #5717 #5751
API design:
OutlierDetector
is similar toCircuitBreaker
, but the state is simpler, only one direction, and optimized for ephemeral resources such as connections and streams.OutlierDetector
determines whether the target is an outlier based ononSuccess()
andonFailure()
events.OutlierDetectingRule
is used to decide whether a request fails.OutlierDetectionDecision
is the result ofOutlierDetectingRule
.OutlierDetectionDecision.FATAL
is a special result that can immediately mark the target as an outlier.Example:
Modifications:
OutlierDetector
,OutlierDetectingRule
andOutlierDetectionDecision
and their implementations tocommon.outlier
package.EventCounter
,EventCount
andSlidingWindowCounter
tocommon.util
package and exposeEventCounter
andEventCount
as public APIs to minimize duplication.SlidingWindowCounter
can be created withEventCounter.ofSlidingWindow(...)
.CircuitBreakerRule
,OutlierDetectingRule
returns a decision synchronously and is simplified to look at headers and causes. Because:OutlierDetector
inHttpSessionHandler
OutlierDetector
is added right afterHttpSessionHandler.invoke()
is called.CircuitBreakerListener.onEventCountUpdated(String,.circuitbreaker.EventCount)
has been deprecated in favor ofCircuitBreakerListener.onEventCountUpdated(String,.util.EventCount)
.ClientFactoryBuilder.connectionOutlierDetection(OutlierDetection)
to detect unhealthy connection.Result:
OutlierDetection
to detect unhealthy connections and close them gracefully.