circuit_breaker

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2022 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 MatchStatusCode

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

匹配接口状态码

func Register

func Register(register eosc.IExtenderDriverRegister)

Types

type CircuitBreaker

type CircuitBreaker struct {
	*Driver
	// 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 http_service.IHttpContext, next http_service.IChain) (err error)

func (*CircuitBreaker) Id

func (c *CircuitBreaker) Id() string

func (*CircuitBreaker) Reset

func (c *CircuitBreaker) Reset(v interface{}, workers map[eosc.RequireId]interface{}) 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:"熔断状态下的返回响应体"`
}

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

func (*Driver) Check

func (d *Driver) Check(v interface{}, workers map[eosc.RequireId]interface{}) error

func (*Driver) ConfigType

func (d *Driver) ConfigType() reflect.Type

func (*Driver) Create

func (d *Driver) Create(id, name string, v interface{}, workers map[eosc.RequireId]interface{}) (eosc.IWorker, error)

type Factory

type Factory struct {
}

func NewFactory

func NewFactory() *Factory

func (*Factory) Create

func (f *Factory) Create(profession string, name string, label string, desc string, params map[string]interface{}) (eosc.IExtenderDriver, error)

func (*Factory) Render added in v0.6.0

func (f *Factory) Render() interface{}

Jump to

Keyboard shortcuts

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