resources

package
v0.12.9 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const CacheSkill = "github.com/eolinker/apinto/resources.resources.ICache"
View Source
const VectorsSkill = "github.com/eolinker/apinto/resources.resources.IVectors"

通过滑动窗口实现的平滑计数器

Variables

View Source
var (
	LocalCache func() ICache
)
View Source
var (
	LocalVector func() IVectors
)

Functions

func NewBoolResult added in v0.9.0

func NewBoolResult(val bool, err error) *boolResult

func NewIntResult added in v0.9.0

func NewIntResult(val int64, err error) *intResult

func NewStatusResult added in v0.9.0

func NewStatusResult(err error) *statusResult

func NewStringResult added in v0.9.0

func NewStringResult(val string, err error) *stringResult

func NewStringResultBytes added in v0.9.0

func NewStringResultBytes(value []byte, err error) *stringResult

func ToBytes added in v0.9.0

func ToBytes(v int64) []byte

func ToInt added in v0.9.0

func ToInt(b []byte) int64

Types

type BoolResult added in v0.9.0

type BoolResult interface {
	Result() (bool, error)
}

type CacheBuilder added in v0.9.0

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

func NewCacheBuilder added in v0.9.0

func NewCacheBuilder(target string) *CacheBuilder

func (*CacheBuilder) GET added in v0.9.0

func (p *CacheBuilder) GET() ICache

type ICache

type ICache interface {
	Set(ctx context.Context, key string, value []byte, expiration time.Duration) StatusResult
	SetNX(ctx context.Context, key string, value []byte, expiration time.Duration) BoolResult
	DecrBy(ctx context.Context, key string, decrement int64, expiration time.Duration) IntResult
	IncrBy(ctx context.Context, key string, decrement int64, expiration time.Duration) IntResult
	Get(ctx context.Context, key string) StringResult
	GetDel(ctx context.Context, key string) StringResult
	Del(ctx context.Context, keys ...string) IntResult
	Tx() TX
}

type IVectors added in v0.9.0

type IVectors interface {
	BuildVector(name string, uni, step time.Duration) (Vector, error)
}

type IntResult added in v0.9.0

type IntResult interface {
	Result() (int64, error)
}

type Metrics added in v0.9.0

type Metrics interface {
	Send(labels map[string]string, fields map[string]interface{})
}

type StatusResult added in v0.9.0

type StatusResult interface {
	Result() error
}

type StringResult added in v0.9.0

type StringResult interface {
	Result() (string, error)
	Bytes() ([]byte, error)
}

type TX added in v0.9.0

type TX interface {
	ICache
	Exec(ctx context.Context) error
}

type Vector added in v0.9.0

type Vector interface {
	Add(key string, delta int64)
	CompareAndAdd(key string, threshold, delta int64) bool
	Get(key string) int64
}

type VectorBuilder added in v0.9.0

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

func NewVectorBuilder added in v0.9.0

func NewVectorBuilder(target string) *VectorBuilder

func (*VectorBuilder) GET added in v0.9.0

func (p *VectorBuilder) GET() IVectors

type VectorsLocalBuild added in v0.9.0

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

func NewVectorsLocalBuild added in v0.9.0

func NewVectorsLocalBuild() *VectorsLocalBuild

func (*VectorsLocalBuild) BuildVector added in v0.9.0

func (v *VectorsLocalBuild) BuildVector(name string, uni, step time.Duration) (Vector, error)

Jump to

Keyboard shortcuts

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