counter

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 17 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       `json:"counterPusher" label:"计数推送器" skill:"github.com/eolinker/apinto/drivers/counter.counter.ICountPusher" required:"false"`
	Match Match                `json:"match" label:"响应匹配规则"`
	Count *separator.CountRule `json:"count" label:"计数规则"`
}

type ICounter added in v0.15.6

type ICounter interface {
	// Lock 锁定次数
	Lock(count int64) error
	// Complete 完成扣次操作
	Complete(count int64) error
	// RollBack 回滚
	RollBack(count int64) error
}

type IKeyGenerator

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

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