validator

package
v5.0.0-...-67dc7c3 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func From

func From(v *Validator) (err error)

func Load

func Load(id string) error

func LoadAll

func LoadAll() error

func Shutdown

func Shutdown() error

func Startup

func Startup() error

func Unload

func Unload(id string) error

Types

type Alarm

type Alarm struct {
	Id        primitive.ObjectID `json:"_id" bson:"_id"`
	ProjectId primitive.ObjectID `json:"project_id" bson:"project_id"`
	SpaceId   primitive.ObjectID `json:"space_id" bson:"space_id"`
	ProductId primitive.ObjectID `json:"product_id" bson:"product_id"`
	DeviceId  primitive.ObjectID `json:"device_id" bson:"device_id"`

	Level   int    `json:"level,omitempty"`   //等级 1 2 3
	Type    string `json:"type,omitempty"`    //类型: 遥测 遥信 等
	Title   string `json:"title,omitempty"`   //标题
	Message string `json:"message,omitempty"` //内容

	Created time.Time `json:"created"`
}

type Compare

type Compare struct {
	Variable string `json:"variable,omitempty"` //变量
	Operator string `json:"operator,omitempty"` //对比算子 > >= < <= !=
	Value    string `json:"value,omitempty"`    //值,支持表达式
	// contains filtered or unexported fields
}

func (*Compare) Eval

func (c *Compare) Eval(ctx map[string]any) (bool, error)

func (*Compare) Init

func (c *Compare) Init() (err error)

type Condition

type Condition struct {
	//外or,内and
	Conditions [][]*Compare `json:"conditions,omitempty"`
}

func (*Condition) Eval

func (a *Condition) Eval(ctx map[string]any) (bool, error)

func (*Condition) Init

func (a *Condition) Init() error

type Context

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

type Validator

type Validator struct {
	Id        string `json:"_id" bson:"_id"`
	ProjectId string `json:"project_id" bson:"project_id"`
	SpaceId   string `json:"space_id" bson:"space_id"`
	ProductId string `json:"product_id" bson:"product_id"`
	DeviceId  string `json:"device_id" bson:"device_id"`

	Condition //直接嵌入条件

	Name     string `json:"name"`
	Level    int    `json:"level,omitempty"`   //等级 1 2 3
	Type     string `json:"type,omitempty"`    //类型: 遥测 遥信 等
	Title    string `json:"title,omitempty"`   //标题
	Message  string `json:"message,omitempty"` //内容
	Disabled bool   `json:"disabled"`

	Delay         int64 `json:"delay,omitempty"`
	Repeat        bool  `json:"repeat,omitempty"`
	RepeatTimeout int64 `json:"repeat_timeout,omitempty" bson:"repeat_timeout,omitempty"`
	RepeatTimes   int   `json:"repeat_times,omitempty" bson:"repeat_times,omitempty"`
	// contains filtered or unexported fields
}

func Get

func Get(id string) *Validator

func (*Validator) Close

func (v *Validator) Close() error

func (*Validator) OnDeviceValuesChange

func (v *Validator) OnDeviceValuesChange(product, device string, values map[string]any)

func (*Validator) OnProjectValuesChange

func (v *Validator) OnProjectValuesChange(project, product, device string, values map[string]any)

func (*Validator) OnSpaceValuesChange

func (v *Validator) OnSpaceValuesChange(space, product, device string, values map[string]any)

func (*Validator) Open

func (v *Validator) Open() error

Jump to

Keyboard shortcuts

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