fuse_strategy

package
v0.19.4 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const Name = "strategy-fuse"

Variables

This section is empty.

Functions

func Check

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

func Create

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

func DoStrategy

func DoStrategy(ctx eocontext.EoContext, next eocontext.IChain, iCache resources.ICache) error

func Register

func Register(register eosc.IExtenderDriverRegister)

Register 注册http路由驱动工厂

Types

type ActuatorSet

type ActuatorSet interface {
	Strategy(ctx eocontext.EoContext, next eocontext.IChain, cache resources.ICache) error
	Set(string, *FuseHandler)
	Del(id string)
}

type Config

type Config struct {
	Name        string                `json:"name" skip:"skip"`
	Description string                `json:"description" skip:"skip"`
	Stop        bool                  `json:"stop" label:"禁用"`
	Priority    int                   `json:"priority" label:"优先级" description:"1-999"`
	Filters     strategy.FilterConfig `json:"filters" label:"过滤规则"`
	Rule        Rule                  `json:"fuse" label:"熔断规则"`
}

type Controller

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

func NewController

func NewController() *Controller

func (*Controller) AllWorkers

func (c *Controller) AllWorkers() []string

func (*Controller) Check

func (c *Controller) Check(cfg interface{}) (profession, name, driver, desc string, err error)

func (*Controller) ConfigType

func (c *Controller) ConfigType() reflect.Type

func (*Controller) Del

func (c *Controller) Del(id string)

func (*Controller) Get

func (c *Controller) Get() interface{}

func (*Controller) Mode

func (c *Controller) Mode() eosc.SettingMode

func (*Controller) Set

func (c *Controller) Set(conf interface{}) (err error)

func (*Controller) Store

func (c *Controller) Store(id string)

type Fuse

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

func (*Fuse) CheckSkill

func (l *Fuse) CheckSkill(skill string) bool

func (*Fuse) Destroy

func (l *Fuse) Destroy() error

func (*Fuse) Reset

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

func (*Fuse) Start

func (l *Fuse) Start() error

func (*Fuse) Stop

func (l *Fuse) Stop() error

type FuseHandler

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

func NewFuseHandler

func NewFuseHandler(conf *Config) (*FuseHandler, error)

func (*FuseHandler) IsFuse

func (f *FuseHandler) IsFuse(ctx context.Context, metrics string, cache resources.ICache) bool

type FuseTimeConf

type FuseTimeConf struct {
	Time    int64 `json:"time" label:"熔断持续时间"`
	MaxTime int64 `json:"max_time" label:"熔断最大持续时间"`
}

type Rule

type Rule struct {
	Metric           string              `json:"metric" label:"熔断维度"`         //熔断维度
	FuseCondition    StatusConditionConf `json:"fuse_condition" label:"熔断条件"` //熔断条件
	FuseTime         FuseTimeConf        `json:"fuse_time" label:"熔断时间"`
	RecoverCondition StatusConditionConf `json:"recover_condition" label:"恢复条件"` //恢复条件
	Response         *response.Response  `json:"response" label:"响应内容"`
}

type StatusConditionConf

type StatusConditionConf struct {
	StatusCodes []int `json:"status_codes" label:"HTTP状态码"`
	Count       int64 `json:"count" label:"次数"`
}

Jump to

Keyboard shortcuts

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