breaker

package
v0.25.3 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CircuitBreaker

type CircuitBreaker struct {
	ModuleName          string   `mapstructure:"module-name" yaml:"module-name" json:"moduleName"`                              // 模块名称
	Enabled             bool     `mapstructure:"enabled" yaml:"enabled" json:"enabled"`                                         // 是否启用断路器
	FailureThreshold    int      `mapstructure:"failure-threshold" yaml:"failure-threshold" json:"failureThreshold"`            // 失败阈值
	SuccessThreshold    int      `mapstructure:"success-threshold" yaml:"success-threshold" json:"successThreshold"`            // 成功阈值
	Timeout             int64    `mapstructure:"timeout" yaml:"timeout" json:"timeout"`                                         // 熔断后恢复时间
	VolumeThreshold     int      `mapstructure:"volume-threshold" yaml:"volume-threshold" json:"volumeThreshold"`               // 最小请求量阈值
	SlidingWindowSize   int      `mapstructure:"sliding-window-size" yaml:"sliding-window-size" json:"slidingWindowSize"`       // 滑动窗口大小
	SlidingWindowBucket int64    `mapstructure:"sliding-window-bucket" yaml:"sliding-window-bucket" json:"slidingWindowBucket"` // 滑动窗口桶大小
	PreventionPaths     []string `mapstructure:"prevention-paths" yaml:"prevention-paths" json:"preventionPaths"`               // 需要保护的路径
	ExcludePaths        []string `mapstructure:"exclude-paths" yaml:"exclude-paths" json:"excludePaths"`                        // 排除的路径
}

CircuitBreaker 断路器配置

func Default

func Default() *CircuitBreaker

Default 创建默认断路器配置

func (*CircuitBreaker) Clone

func (cb *CircuitBreaker) Clone() internal.Configurable

Clone 返回配置的副本

func (*CircuitBreaker) Disable

func (cb *CircuitBreaker) Disable() *CircuitBreaker

Disable 禁用断路器

func (*CircuitBreaker) Enable

func (cb *CircuitBreaker) Enable() *CircuitBreaker

Enable 启用断路器

func (*CircuitBreaker) Get

func (cb *CircuitBreaker) Get() interface{}

Get 返回配置接口

func (*CircuitBreaker) GetLabel

func (cb *CircuitBreaker) GetLabel() string

GetLabel 获取配置标签

func (*CircuitBreaker) Init

func (cb *CircuitBreaker) Init() error

Init 初始化配置

func (*CircuitBreaker) IsEnabled

func (cb *CircuitBreaker) IsEnabled() bool

IsEnabled 检查是否启用

func (*CircuitBreaker) Set

func (cb *CircuitBreaker) Set(data interface{})

Set 设置配置数据

func (*CircuitBreaker) Validate

func (cb *CircuitBreaker) Validate() error

Validate 验证配置

type WebSocketBreaker

type WebSocketBreaker struct {
	ModuleName          string  `mapstructure:"module-name" yaml:"module-name" json:"moduleName"`                              // 模块名称
	Enabled             bool    `mapstructure:"enabled" yaml:"enabled" json:"enabled"`                                         // 是否启用
	FailureThreshold    int     `mapstructure:"failure-threshold" yaml:"failure-threshold" json:"failureThreshold"`            // 失败阈值
	SuccessThreshold    int     `mapstructure:"success-threshold" yaml:"success-threshold" json:"successThreshold"`            // 成功阈值
	Timeout             int64   `mapstructure:"timeout" yaml:"timeout" json:"timeout"`                                         // 熔断恢复时间
	MaxRetries          int     `mapstructure:"max-retries" yaml:"max-retries" json:"maxRetries"`                              // 最大重试次数
	RetryBackoffFactor  float64 `mapstructure:"retry-backoff-factor" yaml:"retry-backoff-factor" json:"retryBackoffFactor"`    // 重试退避因子
	HealthCheckInterval int64   `mapstructure:"health-check-interval" yaml:"health-check-interval" json:"healthCheckInterval"` // 健康检查间隔
	MessageQueueSize    int     `mapstructure:"message-queue-size" yaml:"message-queue-size" json:"messageQueueSize"`          // 消息队列大小
}

WebSocketBreaker WebSocket 专用断路器配置

func DefaultWebSocketBreaker

func DefaultWebSocketBreaker() *WebSocketBreaker

DefaultWebSocketBreaker 创建默认 WebSocket 断路器配置

func (*WebSocketBreaker) Clone

Clone 返回 WebSocket 断路器配置的副本

func (*WebSocketBreaker) Disable

func (wb *WebSocketBreaker) Disable() *WebSocketBreaker

Disable 禁用 WebSocket 断路器

func (*WebSocketBreaker) Enable

func (wb *WebSocketBreaker) Enable() *WebSocketBreaker

Enable 启用 WebSocket 断路器

func (*WebSocketBreaker) Get

func (wb *WebSocketBreaker) Get() interface{}

Get 返回配置接口

func (*WebSocketBreaker) GetLabel

func (wb *WebSocketBreaker) GetLabel() string

GetLabel 获取配置标签

func (*WebSocketBreaker) Init

func (wb *WebSocketBreaker) Init() error

Init 初始化配置

func (*WebSocketBreaker) IsEnabled

func (wb *WebSocketBreaker) IsEnabled() bool

IsEnabled 检查是否启用

func (*WebSocketBreaker) Set

func (wb *WebSocketBreaker) Set(data interface{})

Set 设置配置数据

func (*WebSocketBreaker) Validate

func (wb *WebSocketBreaker) Validate() error

Validate 验证配置

Jump to

Keyboard shortcuts

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