store

package
v3.14.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2017 License: Apache-2.0, Apache-2.0 Imports: 10 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HistoryBigMap = make(map[string]*JudgeItemMap)

这是个线程不安全的大Map,需要提前初始化好

Functions

func CheckExpression

func CheckExpression(L *SafeLinkedList, firstItem *model.JudgeItem, now int64)

func CheckStrategy

func CheckStrategy(L *SafeLinkedList, firstItem *model.JudgeItem, now int64)

func InitHistoryBigMap

func InitHistoryBigMap()

func Judge

func Judge(L *SafeLinkedList, firstItem *model.JudgeItem, now int64)

Types

type AllFunction

type AllFunction struct {
	Function
	Limit      int
	Operator   string
	RightValue float64
}

func (AllFunction) Compute

func (this AllFunction) Compute(L *SafeLinkedList) (vs []*model.HistoryData, leftValue float64, isTriggered bool, isEnough bool)

type AvgFunction

type AvgFunction struct {
	Function
	Limit      int
	Operator   string
	RightValue float64
}

func (AvgFunction) Compute

func (this AvgFunction) Compute(L *SafeLinkedList) (vs []*model.HistoryData, leftValue float64, isTriggered bool, isEnough bool)

type DiffFunction

type DiffFunction struct {
	Function
	Limit      int
	Operator   string
	RightValue float64
}

func (DiffFunction) Compute

func (this DiffFunction) Compute(L *SafeLinkedList) (vs []*model.HistoryData, leftValue float64, isTriggered bool, isEnough bool)

只要有一个点的diff触发阈值,就报警

type Function

type Function interface {
	Compute(L *SafeLinkedList) (vs []*model.HistoryData, leftValue float64, isTriggered bool, isEnough bool)
}

func ParseFuncFromString

func ParseFuncFromString(str string, operator string, rightValue float64) (fn Function, err error)

@str: e.g. all(#3) sum(#3) avg(#10) diff(#10)

type JudgeItemMap

type JudgeItemMap struct {
	sync.RWMutex
	M map[string]*SafeLinkedList
}

func NewJudgeItemMap

func NewJudgeItemMap() *JudgeItemMap

func (*JudgeItemMap) BatchDelete

func (this *JudgeItemMap) BatchDelete(keys []string)

func (*JudgeItemMap) CleanStale

func (this *JudgeItemMap) CleanStale(before int64)

func (*JudgeItemMap) Delete

func (this *JudgeItemMap) Delete(key string)

func (*JudgeItemMap) Get

func (this *JudgeItemMap) Get(key string) (*SafeLinkedList, bool)

func (*JudgeItemMap) Len

func (this *JudgeItemMap) Len() int

func (*JudgeItemMap) PushFrontAndMaintain

func (this *JudgeItemMap) PushFrontAndMaintain(key string, val *model.JudgeItem, maxCount int, now int64)

func (*JudgeItemMap) Set

func (this *JudgeItemMap) Set(key string, val *SafeLinkedList)

type MaxFunction

type MaxFunction struct {
	Function
	Limit      int
	Operator   string
	RightValue float64
}

func (MaxFunction) Compute

func (this MaxFunction) Compute(L *SafeLinkedList) (vs []*model.HistoryData, leftValue float64, isTriggered bool, isEnough bool)

type MinFunction

type MinFunction struct {
	Function
	Limit      int
	Operator   string
	RightValue float64
}

func (MinFunction) Compute

func (this MinFunction) Compute(L *SafeLinkedList) (vs []*model.HistoryData, leftValue float64, isTriggered bool, isEnough bool)

type PDiffFunction

type PDiffFunction struct {
	Function
	Limit      int
	Operator   string
	RightValue float64
}

pdiff(#3)

func (PDiffFunction) Compute

func (this PDiffFunction) Compute(L *SafeLinkedList) (vs []*model.HistoryData, leftValue float64, isTriggered bool, isEnough bool)

type SafeLinkedList

type SafeLinkedList struct {
	sync.RWMutex
	L *list.List
}

func (*SafeLinkedList) Front

func (this *SafeLinkedList) Front() *list.Element

func (*SafeLinkedList) HistoryData

func (this *SafeLinkedList) HistoryData(limit int) ([]*model.HistoryData, bool)

@param limit 至多返回这些,如果不够,有多少返回多少 @return bool isEnough

func (*SafeLinkedList) Len

func (this *SafeLinkedList) Len() int

func (*SafeLinkedList) PushFront

func (this *SafeLinkedList) PushFront(v interface{}) *list.Element

func (*SafeLinkedList) PushFrontAndMaintain

func (this *SafeLinkedList) PushFrontAndMaintain(v *model.JudgeItem, maxCount int) bool

@return needJudge 如果是false不需要做judge,因为新上来的数据不合法

func (*SafeLinkedList) ToSlice

func (this *SafeLinkedList) ToSlice() []*model.JudgeItem

type SumFunction

type SumFunction struct {
	Function
	Limit      int
	Operator   string
	RightValue float64
}

func (SumFunction) Compute

func (this SumFunction) Compute(L *SafeLinkedList) (vs []*model.HistoryData, leftValue float64, isTriggered bool, isEnough bool)

Jump to

Keyboard shortcuts

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