Documentation
¶
Index ¶
- func AllowRequest(channelId int64) bool
- func InitManager(failureThreshold, successThreshold int, timeout time.Duration)
- func RecordFailure(channelId int64)
- func RecordSuccess(channelId int64)
- func RemoveChannel(channelId int64)
- func ResetChannel(channelId int64)
- type CircuitBreaker
- type Manager
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowRequest ¶
AllowRequest 检查指定渠道的断路器是否允许请求 供 middleware/distributor.go 在选择渠道前调用
func InitManager ¶
InitManager 初始化全局断路器管理器(应在 main.go 中调用)
func RecordFailure ¶
func RecordFailure(channelId int64)
RecordFailure 记录指定渠道的失败请求 供 controller/relay.go 在请求失败后调用
func RecordSuccess ¶
func RecordSuccess(channelId int64)
RecordSuccess 记录指定渠道的成功请求 供 controller/relay.go 在请求成功后调用
Types ¶
type CircuitBreaker ¶
type CircuitBreaker struct {
// contains filtered or unexported fields
}
CircuitBreaker 单个渠道的断路器
func New ¶
func New(failureThreshold, successThreshold int, timeout time.Duration) *CircuitBreaker
New 创建新的断路器实例
func (*CircuitBreaker) AllowRequest ¶
func (cb *CircuitBreaker) AllowRequest() bool
AllowRequest 判断是否允许请求通过
func (*CircuitBreaker) RecordFailure ¶
func (cb *CircuitBreaker) RecordFailure()
RecordFailure 记录失败请求
func (*CircuitBreaker) RecordSuccess ¶
func (cb *CircuitBreaker) RecordSuccess()
RecordSuccess 记录成功请求
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager 管理所有渠道的断路器实例 线程安全,懒初始化
func (*Manager) GetAllStates ¶
GetAllStates 获取所有断路器的状态(用于 API 查询 / 调试)
Click to show internal directories.
Click to hide internal directories.