Documentation ¶
Index ¶
- Constants
- type CircuitBreaker
- func (g *CircuitBreaker) CircuitBreak(instances []model.Instance) (*circuitbreaker.Result, error)
- func (g *CircuitBreaker) Destroy() error
- func (g *CircuitBreaker) GetErrorCountConfig(namespace string, service string) config.ErrorCountConfig
- 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) GetContinuousErrorThreshold() int
- func (r *Config) GetMetricNumBuckets() int
- func (r *Config) GetMetricStatTimeWindow() time.Duration
- func (r *Config) SetContinuousErrorThreshold(value int)
- func (r *Config) SetDefault()
- func (r *Config) SetMetricNumBuckets(value int)
- func (r *Config) SetMetricStatTimeWindow(value time.Duration)
- func (r *Config) Verify() error
Constants ¶
View Source
const ( // DefaultContinuousErrorThreshold 默认可触发熔断的连续错误数,默认10 DefaultContinuousErrorThreshold = 10 // DefaultMetricStatTimeWindow 连续错误数统计时间窗口,默认1分钟 DefaultMetricStatTimeWindow = 1 * time.Minute // MinMetricStatTimeWindow 最小连续错误数统计时间窗口 MinMetricStatTimeWindow = 1 * time.Second // DefaultErrCountMetricBucketCount 连续错误数统计滑桶数量 DefaultErrCountMetricBucketCount = 10 )
定义连续错误熔断配置的默认值
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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) GetErrorCountConfig ¶
func (g *CircuitBreaker) GetErrorCountConfig(namespace string, service string) config.ErrorCountConfig
GetErrorCountConfig .获取错误的连续错误数熔断配置
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 { // 连续错误数阈值 ContinuousErrorThreshold int `yaml:"continuousErrorThreshold" json:"continuousErrorThreshold"` // 连续错误数统计时间窗口 MetricStatTimeWindow *time.Duration `yaml:"metricStatTimeWindow" json:"metricStatTimeWindow"` // 连续错误数统计滑桶数量 MetricNumBuckets int `yaml:"metricNumBuckets" json:"metricNumBuckets"` }
Config 连续错误熔断的配置对象
func (*Config) GetBucketInterval ¶
GetBucketInterval 获取滑桶时间间隔
func (*Config) GetContinuousErrorThreshold ¶
GetContinuousErrorThreshold 连续错误数阈值
func (*Config) GetMetricNumBuckets ¶
GetMetricNumBuckets 连续错误数统计滑桶数量
func (*Config) GetMetricStatTimeWindow ¶
GetMetricStatTimeWindow 连续错误数统计时间窗口
func (*Config) SetContinuousErrorThreshold ¶
SetContinuousErrorThreshold 设置连续错误数阈值
func (*Config) SetMetricNumBuckets ¶
SetMetricNumBuckets 设置连续错误数统计滑桶数量
func (*Config) SetMetricStatTimeWindow ¶
SetMetricStatTimeWindow 设置连续错误数统计时间窗口
Click to show internal directories.
Click to hide internal directories.