grey_strategy

package
v0.14.9 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const Name = "strategy-grey"
View Source
const SessionName = "Apinto-Session"

Variables

This section is empty.

Functions

func Check added in v0.9.0

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

func Create added in v0.9.0

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

func DoStrategy added in v0.9.0

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

func NewGreyApp added in v0.12.5

func Register

func Register(register eosc.IExtenderDriverRegister)

Register 注册http路由驱动工厂

Types

type ActuatorSet

type ActuatorSet interface {
	strategy.IStrategyHandler
	Set(string, *GreyHandler)
	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:"grey" 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 Grey

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

func (*Grey) CheckSkill

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

func (*Grey) Destroy

func (l *Grey) Destroy() error

func (*Grey) Reset

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

func (*Grey) Start

func (l *Grey) Start() error

func (*Grey) Stop

func (l *Grey) Stop() error

type GreyApp added in v0.12.5

type GreyApp struct {
	eocontext.BalanceHandler
	// contains filtered or unexported fields
}

func (*GreyApp) Scheme added in v0.12.5

func (g *GreyApp) Scheme() string

func (*GreyApp) TimeOut added in v0.12.5

func (g *GreyApp) TimeOut() time.Duration

type GreyHandler

type GreyHandler struct {
	strategy.IFilter

	GreyMatch
	// contains filtered or unexported fields
}

func NewGreyHandler

func NewGreyHandler(conf *Config) (*GreyHandler, error)

func (*GreyHandler) Close added in v0.12.5

func (g *GreyHandler) Close()

func (*GreyHandler) DoGrey added in v0.12.5

func (g *GreyHandler) DoGrey(ctx eocontext.EoContext)

func (*GreyHandler) IsStop added in v0.12.5

func (g *GreyHandler) IsStop() bool

func (*GreyHandler) Nodes added in v0.12.5

func (g *GreyHandler) Nodes() []eocontext.INode

func (*GreyHandler) Priority added in v0.12.5

func (g *GreyHandler) Priority() int

func (*GreyHandler) Scheme added in v0.12.5

func (g *GreyHandler) Scheme() string

func (*GreyHandler) TimeOut added in v0.12.5

func (g *GreyHandler) TimeOut() time.Duration

type GreyMatch added in v0.12.5

type GreyMatch interface {
	Match(ctx eocontext.EoContext) bool
}

type IGreyHandler added in v0.12.5

type IGreyHandler interface {
	strategy.IFilter
	GreyMatch
	DoGrey(ctx eocontext.EoContext)
	IsStop() bool
	Priority() int
}

type Matching

type Matching struct {
	Type  string `json:"type"  label:"类型" enum:"header,query,cookie"`
	Name  string `json:"name"  label:"参数名"`
	Value string `json:"value"  label:"值规" `
}

type Robin

type Robin struct {
	Weighted []Weighted
	Training []*Training
}

func NewRobin

func NewRobin(servers ...Weighted) *Robin

NewRobin 初始化一个池子

func (*Robin) Select

func (l *Robin) Select(remove ...uint) Weighted

Select remove为需要屏蔽的ID,

type Rule

type Rule struct {
	KeepSession  bool        `json:"keep_session" label:"会话保持规则"`
	Nodes        []string    `json:"nodes" label:"灰度节点"`
	Distribution string      `json:"distribution" label:"流量分配方式" enum:"percent,match"` // percent   match
	Percent      int         `json:"percent" label:"灰度节点流量占比" description:"1-9999"`    // 灰度的百分比 四位数
	Matching     []*Matching `json:"matching" label:"高级匹配"`
}

func (*Rule) GetNodes

func (r *Rule) GetNodes() []eocontext.INode

type Training

type Training struct {
	Server        Weighted
	Weight        int //初始化设置权重值
	CurrentWeight int //目前的权重值
}

type Weighted

type Weighted interface {
	GetId() uint32
	GetWeight() int
}

Jump to

Keyboard shortcuts

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