errorcount

package
v1.5.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 15 Imported by: 0

Documentation

Index

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) Destroy

func (g *CircuitBreaker) Destroy() error

Destroy 销毁插件,可用于释放资源

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) Name

func (g *CircuitBreaker) Name() string

Name 插件名,一个类型下插件名唯一

func (*CircuitBreaker) Stat

func (g *CircuitBreaker) Stat(gauge model.InstanceGauge) (bool, error)

Stat 实时上报健康状态并进行连续失败熔断判断,返回当前实例是否需要进行立即熔断

func (*CircuitBreaker) Type

func (g *CircuitBreaker) Type() common2.Type

Type 插件类型

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

func (r *Config) GetBucketInterval() time.Duration

GetBucketInterval 获取滑桶时间间隔

func (*Config) GetContinuousErrorThreshold

func (r *Config) GetContinuousErrorThreshold() int

GetContinuousErrorThreshold 连续错误数阈值

func (*Config) GetMetricNumBuckets

func (r *Config) GetMetricNumBuckets() int

GetMetricNumBuckets 连续错误数统计滑桶数量

func (*Config) GetMetricStatTimeWindow

func (r *Config) GetMetricStatTimeWindow() time.Duration

GetMetricStatTimeWindow 连续错误数统计时间窗口

func (*Config) SetContinuousErrorThreshold

func (r *Config) SetContinuousErrorThreshold(value int)

SetContinuousErrorThreshold 设置连续错误数阈值

func (*Config) SetDefault

func (r *Config) SetDefault()

SetDefault 设置连续错误熔断配置默认值

func (*Config) SetMetricNumBuckets

func (r *Config) SetMetricNumBuckets(value int)

SetMetricNumBuckets 设置连续错误数统计滑桶数量

func (*Config) SetMetricStatTimeWindow

func (r *Config) SetMetricStatTimeWindow(value time.Duration)

SetMetricStatTimeWindow 设置连续错误数统计时间窗口

func (*Config) Verify

func (r *Config) Verify() error

Verify 检验连续错误熔断配置

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL