nsq

package
v0.15.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	Name = "nsq-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 {
	Scopes        []string `json:"scopes" label:"作用域"`
	Topic         string   `json:"topic" yaml:"topic" label:"topic"`
	Address       []string `json:"address" yaml:"address" label:"请求地址"`
	AuthSecret    string   `json:"auth_secret" yaml:"auth_secret" label:"鉴权secret"`
	Params        []*Param `json:"params" label:"参数列表"`
	CountParamKey string   `json:"count_param_key" label:"计数参数"`
	PushMode      string   `json:"push_mode" label:"推送模式" enum:"single,multi" default:"multi"`
}

type Counter

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

func NewCounter

func NewCounter(key string, body interface{}, countExpr jp.Expr) *Counter

func (*Counter) Add

func (c *Counter) Add(count int64)

func (*Counter) Count

func (c *Counter) Count() int64

func (*Counter) Generate

func (c *Counter) Generate(count int64) (interface{}, error)

func (*Counter) Key

func (c *Counter) Key() string

type CounterHandler

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

func (*CounterHandler) Generate

func (c *CounterHandler) Generate() ([][]byte, error)

func (*CounterHandler) GetCounter

func (c *CounterHandler) GetCounter(key string, variables map[string]string) ICounter

type ICounter

type ICounter interface {
	Key() string
	Add(count int64)
	Count() int64
	// Generate 返回计数器生成的信息,同时清理计数器
	Generate(count int64) (interface{}, error)
}

ICounter 计数器

type Param

type Param struct {
	Key   string `json:"key" label:"参数名(JSON PATH格式)"`
	Value string `json:"value" label:"参数值"`
	Type  string `json:"type" label:"参数类型" enum:"string,int,boolean" default:"string"`
}

Jump to

Keyboard shortcuts

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