counter

package
v0.14.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	Name = "counter"
)

Variables

This section is empty.

Functions

func Create

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

func NewFactory

func NewFactory() eosc.IExtenderDriverFactory

func Register

func Register(register eosc.IExtenderDriverRegister)

Types

type Config

type Config struct {
	Key         string               `json:"key" label:"格式化Key" required:"true"`
	Cache       eosc.RequireId       `json:"cache" label:"缓存计数器" skill:"github.com/eolinker/apinto/resources.resources.ICache" required:"false"`
	Counter     eosc.RequireId       `json:"counter" label:"计数器" skill:"github.com/eolinker/apinto/drivers/counter.counter.IClient" required:"false"`
	CountPusher eosc.RequireId       `` /* 133-byte string literal not displayed */
	Match       Match                `json:"match" label:"响应匹配规则"`
	Count       *separator.CountRule `json:"count" label:"计数规则"`
	CountMode   string               `json:"count_mode" label:"计数模式" enum:"local,redis"`
}

type IKeyGenerator

type IKeyGenerator interface {
	Key(ctx http_service.IHttpContext) string
	Variables(ctx http_service.IHttpContext) eosc.Untyped[string, string]
}

type LocalCounter

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

LocalCounter 本地计数器

func (*LocalCounter) Complete

func (c *LocalCounter) Complete(count int64) error

func (*LocalCounter) Lock

func (c *LocalCounter) Lock(count int64) error

func (*LocalCounter) RollBack

func (c *LocalCounter) RollBack(count int64) error

type Match

type Match struct {
	Params      []*matcher.MatchParam `json:"params" label:"匹配参数列表"`
	StatusCodes []int                 `json:"status_codes" label:"匹配响应状态码列表"`
	Type        string                `json:"type" label:"匹配类型" enum:"json"`
}

func (*Match) GenerateHandler

func (m *Match) GenerateHandler() []matcher.IMatcher

type RedisCounter

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

func (*RedisCounter) Complete

func (r *RedisCounter) Complete(count int64) error

func (*RedisCounter) Lock

func (r *RedisCounter) Lock(count int64) error

func (*RedisCounter) RollBack

func (r *RedisCounter) RollBack(count int64) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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