circuitbreaker

package
v1.3.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2022 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InstanceCircuitBreaker

type InstanceCircuitBreaker interface {
	plugin.Plugin
	// Stat 进行调用统计,返回当前实例是否需要进行立即熔断
	Stat(model.InstanceGauge) (bool, error)
	// CircuitBreak 进行熔断计算,返回需要进行状态转换的实例ID
	// 入参包括全量服务实例,以及当前周期的健康探测结果
	CircuitBreak(instances []model.Instance) (*Result, error)
}

InstanceCircuitBreaker 【扩展点接口】节点熔断

type Proxy

type Proxy struct {
	InstanceCircuitBreaker
	// contains filtered or unexported fields
}

Proxy .proxy of InstanceCircuitBreaker

func (*Proxy) CircuitBreak

func (p *Proxy) CircuitBreak(instances []model.Instance) (*Result, error)

CircuitBreak proxy InstanceCircuitBreaker CircuitBreak

func (*Proxy) SetRealPlugin

func (p *Proxy) SetRealPlugin(plug plugin.Plugin, engine model.Engine)

SetRealPlugin 设置

func (*Proxy) Stat

func (p *Proxy) Stat(gauge model.InstanceGauge) (bool, error)

Stat proxy InstanceCircuitBreaker stat

type Result

type Result struct {
	Now time.Time
	// 需要开启熔断器的实例ID
	InstancesToOpen model.HashSet
	// 需要转换成半开状态的实例ID
	InstancesToHalfOpen model.HashSet
	// 需要关闭熔断器的实例ID
	InstancesToClose model.HashSet
	// 该熔断器在实例进入半开状态后最多允许的请求数
	RequestCountAfterHalfOpen int
}

Result 熔断结算结果

func NewCircuitBreakerResult

func NewCircuitBreakerResult(now time.Time) *Result

NewCircuitBreakerResult 创建熔断结果对象

func (*Result) IsEmpty

func (r *Result) IsEmpty() bool

IsEmpty result has status changing instances

func (*Result) Merge

func (r *Result) Merge(result *Result)

Merge merge results

Jump to

Keyboard shortcuts

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