circuit_breaker

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BreakerDisable    = 0
	BreakerEnable     = 1
	BreakerRecovering = 2
)
View Source
const (
	Name = "circuit_breaker"
)

Variables

This section is empty.

Functions

func Check added in v0.9.0

func Check(conf *Config, workers map[eosc.RequireId]eosc.IWorker) error

func Create added in v0.9.0

func Create(id, name string, conf *Config, workers map[eosc.RequireId]eosc.IWorker) (eosc.IWorker, error)

func MatchStatusCode

func MatchStatusCode(matchStatusCodes string, ctx http_service.IHttpContext) bool

匹配接口状态码

func NewFactory

func NewFactory() eosc.IExtenderDriverFactory

func Register

func Register(register eosc.IExtenderDriverRegister)

Types

type CircuitBreaker

type CircuitBreaker struct {
	drivers.WorkerBase
	// contains filtered or unexported fields
}

func (*CircuitBreaker) CheckSkill

func (c *CircuitBreaker) CheckSkill(skill string) bool

func (*CircuitBreaker) Destroy

func (c *CircuitBreaker) Destroy()

func (*CircuitBreaker) DoFilter

func (c *CircuitBreaker) DoFilter(ctx eocontext.EoContext, next eocontext.IChain) (err error)

func (*CircuitBreaker) DoHttpFilter added in v0.8.0

func (c *CircuitBreaker) DoHttpFilter(ctx http_service.IHttpContext, next eocontext.IChain) error

func (*CircuitBreaker) Reset

func (c *CircuitBreaker) Reset(v interface{}, workers map[eosc.RequireId]eosc.IWorker) error

func (*CircuitBreaker) Start

func (c *CircuitBreaker) Start() error

func (*CircuitBreaker) Stop

func (c *CircuitBreaker) Stop() error

type CircuitBreakerInfo

type CircuitBreakerInfo struct {
	CircuitBreakerState     int   `json:"circuit_breaker_state"`
	FailCounts              int   `json:"fail_counts"`
	SuccessCounts           int   `json:"success_counts"`
	TripTime                int64 `json:"trip_time"`
	StartTime               int64 `json:"start_time"`
	RecoveringSuccessCounts int   `json:"recovering_success_counts"`
}

func (*CircuitBreakerInfo) ResetCircuitBreakerInfo

func (cb *CircuitBreakerInfo) ResetCircuitBreakerInfo(state int, resetStartTime bool)

重置熔断当前状态信息

type Config

type Config struct {
	MatchCodes      string            `json:"match_codes" label:"匹配状态码" description:"多个状态码之间使用英文逗号隔开"`
	MonitorPeriod   int               `json:"monitor_period" label:"监控期" minimum:"1" description:"单位:秒,最小值:1"`
	MinimumRequests int               `` /* 132-byte string literal not displayed */
	FailurePercent  float64           `` /* 129-byte string literal not displayed */
	BreakPeriod     int64             `json:"break_period" label:"熔断期" minimum:"1" description:"最小值:1"`
	SuccessCounts   int               `` /* 166-byte string literal not displayed */
	BreakerCode     int               `json:"breaker_code" label:"熔断状态下返回的响应状态码" minimum:"100" description:"最小值:100"`
	Headers         map[string]string `json:"headers" label:"熔断状态下新增的返回头部值"`
	Body            string            `json:"body" label:"熔断状态下的返回响应体"`
}

Jump to

Keyboard shortcuts

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