Documentation ¶
Index ¶
- Constants
- func ToErrorRateThreshold(errorRatePercent int) float64
- type CircuitBreaker
- func (g *CircuitBreaker) CircuitBreak(instances []model.Instance) (*circuitbreaker.Result, error)
- func (g *CircuitBreaker) Destroy() error
- func (g *CircuitBreaker) Init(ctx *plugin.InitContext) error
- func (g *CircuitBreaker) IsEnable(cfg config.Configuration) bool
- func (g *CircuitBreaker) Name() string
- func (g *CircuitBreaker) Stat(gauge model.InstanceGauge) (bool, error)
- func (g *CircuitBreaker) Type() common2.Type
- type Config
- func (r *Config) GetBucketInterval() time.Duration
- func (r *Config) GetErrorRatePercent() int
- func (r *Config) GetMetricNumBuckets() int
- func (r *Config) GetMetricStatTimeWindow() time.Duration
- func (r *Config) GetRequestVolumeThreshold() int
- func (r *Config) SetDefault()
- func (r *Config) SetErrorRatePercent(value int)
- func (r *Config) SetMetricNumBuckets(value int)
- func (r *Config) SetMetricStatTimeWindow(value time.Duration)
- func (r *Config) SetRequestVolumeThreshold(value int)
- func (r *Config) Verify() error
Constants ¶
View Source
const ( // DefaultRequestVolumeThreshold 只有请求数达到某个阈值才执行熔断计算,默认10 DefaultRequestVolumeThreshold = 10 // DefaultErrorRateThreshold 触发熔断的错误率阈值,默认0.5 DefaultErrorRateThreshold float64 = 0.5 // DefaultErrorRatePercent 默认错误率百分比 DefaultErrorRatePercent int = 50 // MaxErrorRatePercent 最大错误率百分比 MaxErrorRatePercent int = 100 // DefaultMetricStatTimeWindow 错误率统计时间窗口,默认1分钟 DefaultMetricStatTimeWindow = 60 * time.Second // MinMetricStatTimeWindow 最小错误率统计时间窗口,1s MinMetricStatTimeWindow = 1 * time.Second // DefaultMetricNumBuckets 统计窗口细分的桶数量,默认10 DefaultMetricNumBuckets = 5 // MinMetricStatBucketSize 最小的滑窗时间片,1ms MinMetricStatBucketSize = 1 * time.Millisecond )
定义错误率熔断配置的默认值
Variables ¶
This section is empty.
Functions ¶
func ToErrorRateThreshold ¶
ToErrorRateThreshold 转换成熔断错误率阈值
Types ¶
type CircuitBreaker ¶
type CircuitBreaker struct { *plugin.PluginBase // contains filtered or unexported fields }
CircuitBreaker 基于错误率的默认熔断规则
func (*CircuitBreaker) CircuitBreak ¶
func (g *CircuitBreaker) CircuitBreak(instances []model.Instance) (*circuitbreaker.Result, error)
CircuitBreak .熔断 定期进行熔断计算,返回需要进行状态转换的实例ID 入参包括全量服务实例,以及当前周期的健康探测结果
func (*CircuitBreaker) Init ¶
func (g *CircuitBreaker) Init(ctx *plugin.InitContext) error
Init 初始化插件
func (*CircuitBreaker) IsEnable ¶
func (g *CircuitBreaker) IsEnable(cfg config.Configuration) bool
IsEnable enable
func (*CircuitBreaker) Stat ¶
func (g *CircuitBreaker) Stat(gauge model.InstanceGauge) (bool, error)
Stat 实时上报健康状态并进行失败率统计
type Config ¶
type Config struct { RequestVolumeThreshold int `yaml:"requestVolumeThreshold" json:"requestVolumeThreshold"` ErrorRatePercent int `yaml:"errorRatePercent" json:"errorRatePercent"` // Deprecated: 请使用ErrorRatePercent ErrorRateThreshold float64 `yaml:"errorRateThreshold" json:"errorRateThreshold"` MetricStatTimeWindow *time.Duration `yaml:"metricStatTimeWindow" json:"metricStatTimeWindow"` MetricNumBuckets int `yaml:"metricNumBuckets" json:"metricNumBuckets"` }
Config 基于错误率熔断器的配置结构
func (*Config) GetBucketInterval ¶
GetBucketInterval 获取滑桶时间间隔
func (*Config) GetErrorRatePercent ¶
GetErrorRatePercent 触发熔断的错误率阈值,取值范围(0, 100]
func (*Config) GetMetricNumBuckets ¶
GetMetricNumBuckets 统计窗口细分的桶数量
func (*Config) GetMetricStatTimeWindow ¶
GetMetricStatTimeWindow 错误率统计时间窗口
func (*Config) GetRequestVolumeThreshold ¶
GetRequestVolumeThreshold 触发错误率熔断的请求量阈值
func (*Config) SetErrorRatePercent ¶
SetErrorRatePercent 设置错误率阈值
func (*Config) SetMetricNumBuckets ¶
SetMetricNumBuckets 设置统计窗口细分的桶数量
func (*Config) SetMetricStatTimeWindow ¶
SetMetricStatTimeWindow 设置错误率统计时间窗口
func (*Config) SetRequestVolumeThreshold ¶
SetRequestVolumeThreshold 设置触发错误率熔断的请求量阈值
Click to show internal directories.
Click to hide internal directories.