counter

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 19 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"`
	Match   *Match               `json:"match" label:"响应匹配规则"`
	Count   *separator.CountRule `json:"count" label:"计数规则"`
}

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 NewLocalCounter

func NewLocalCounter(key string, variables eosc.Untyped[string, string], client scope_manager.IProxyOutput[counter.IClient]) *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