Documentation ¶
Index ¶
- Constants
- Variables
- func Check(cfg *Config, workers map[eosc.RequireId]eosc.IWorker) error
- func Create(id, name string, v *Config, workers map[eosc.RequireId]eosc.IWorker) (eosc.IWorker, error)
- func DoStrategy(ctx eocontext.EoContext, next eocontext.IChain, scalars *Scalars) error
- func NewActuator() *actuatorHttp
- func Register(register eosc.IExtenderDriverRegister)
- func RegisterActuator(handler ActuatorsHandler)
- type ActuatorSet
- type ActuatorsHandler
- type Config
- type Controller
- func (c *Controller) AllWorkers() []string
- func (c *Controller) Check(cfg interface{}) (profession, name, driver, desc string, err error)
- func (c *Controller) ConfigType() reflect.Type
- func (c *Controller) Del(id string)
- func (c *Controller) Get() interface{}
- func (c *Controller) Mode() eosc.SettingMode
- func (c *Controller) Set(conf interface{}) (err error)
- func (c *Controller) Store(id string)
- type Header
- type Limiting
- type LimitingHandler
- type Rule
- type Scalars
- type Set
- type StrategyResponseConf
- type Threshold
- type ThresholdUint
Constants ¶
View Source
const Name = "strategy-limiting"
Variables ¶
View Source
var (
ErrorLimitingRefuse = errors.New("refuse by limiting strategy")
)
Functions ¶
func DoStrategy ¶ added in v0.9.0
func NewActuator ¶
func NewActuator() *actuatorHttp
func RegisterActuator ¶
func RegisterActuator(handler ActuatorsHandler)
Types ¶
type ActuatorSet ¶
type ActuatorsHandler ¶
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:"limiting" label:"限流规则" description:"限流规则"` }
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 Limiting ¶
type Limiting struct { drivers.WorkerBase // contains filtered or unexported fields }
func (*Limiting) CheckSkill ¶
type LimitingHandler ¶
type LimitingHandler struct {
// contains filtered or unexported fields
}
func NewLimitingHandler ¶
func NewLimitingHandler(conf *Config) (*LimitingHandler, error)
func (*LimitingHandler) Filter ¶
func (l *LimitingHandler) Filter() strategy.IFilter
func (*LimitingHandler) Metrics ¶
func (l *LimitingHandler) Metrics() metrics.Metrics
func (*LimitingHandler) Name ¶
func (l *LimitingHandler) Name() string
func (*LimitingHandler) Priority ¶
func (l *LimitingHandler) Priority() int
func (*LimitingHandler) Response ¶ added in v0.9.0
func (l *LimitingHandler) Response() StrategyResponseConf
func (*LimitingHandler) Stop ¶
func (l *LimitingHandler) Stop() bool
type Rule ¶
type Rule struct { Metrics []string `json:"metrics" label:"限流计数器名"` Query Threshold `json:"query" label:"请求限制" description:"按请求次数"` Traffic Threshold `json:"traffic" label:"流量限制" description:"按请求内容大小"` Response StrategyResponseConf `json:"response" label:"响应内容"` }
type StrategyResponseConf ¶ added in v0.9.0
type StrategyResponseConf struct { StatusCode int `json:"status_code" label:"HTTP状态码"` ContentType string `json:"content_type" label:"Content-Type"` Charset string `json:"charset" label:"Charset"` Headers []*Header `json:"header" label:"Header参数"` Body string `json:"body" label:"Body"` }
StrategyResponseConf 策略返回内容配置
func (*StrategyResponseConf) SetBodyLabel ¶ added in v0.9.0
func (s *StrategyResponseConf) SetBodyLabel(labels map[string]string) string
type ThresholdUint ¶
Click to show internal directories.
Click to hide internal directories.