TsgcWSCircuitBreaker › 属性 › Thresholds
将熔断器从关闭状态切换到打开状态的条件(故障计数、故障率和慢调用率)。
property Thresholds: TsgcCircuitBreakerThresholds read FThresholds
write SetThresholds;
—
当在当前滚动窗口内达到任何已配置的阈值时,断路器打开。子属性:Enabled(启用基于阈值的打开)、FailureCount(窗口内触发断路器的绝对失败次数,默认 5)、FailureRatePercent(0-100,达到 MinCalls 后触发断路器的失败百分比,默认 50)、SlowCallDurationMs(超过此毫秒数的成功调用也被计为"慢速",默认 3000)、SlowCallRatePercent(0-100,触发断路器的慢速调用百分比;0 禁用慢速调用检测)、MinCalls(评估速率阈值前需观察的最小调用次数,默认 10,避免在小样本上触发)。将适中的 FailureCount 与非零 MinCalls 和 FailureRatePercent 结合使用,可同时捕捉突发故障和渐进性降级。
// Open after 5 failures, or 50% failure rate on 10+ calls, or 60% slow calls
sgcWSCircuitBreaker1.Thresholds.Enabled := True;
sgcWSCircuitBreaker1.Thresholds.FailureCount := 5;
sgcWSCircuitBreaker1.Thresholds.FailureRatePercent := 50;
sgcWSCircuitBreaker1.Thresholds.MinCalls := 10;
sgcWSCircuitBreaker1.Thresholds.SlowCallDurationMs := 3000;
sgcWSCircuitBreaker1.Thresholds.SlowCallRatePercent := 60;