rules_engine

package
v0.0.0-...-6312dd6 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

func NewEngine

func NewEngine(db RuleDB, container container.Container) *Engine

func (*Engine) AddRule

func (e *Engine) AddRule(desc RuleDescription) (*Rule, error)

func (*Engine) DeleteRule

func (e *Engine) DeleteRule(i int64) error

func (*Engine) GetRule

func (e *Engine) GetRule(id int64) *Rule

func (*Engine) GetRules

func (e *Engine) GetRules() map[int64]*Rule

func (*Engine) UpdateRule

func (e *Engine) UpdateRule(i int64, desc RuleDescription) error

type Rule

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

func FromDescription

func FromDescription(desc RuleDescription, container things.Container) *Rule

func NewRule

func NewRule(name string, enabled bool, trigger triggers.Entity, effect effects.Entity) *Rule

func (Rule) MarshalJSON

func (r Rule) MarshalJSON() ([]byte, error)

func (*Rule) Start

func (r *Rule) Start()

func (*Rule) Stop

func (r *Rule) Stop()

type RuleDB

type RuleDB interface {
	CreateRule(rule Rule) (int64, error)
	UpdateRule(ruleId int64, r Rule) error
	DeleteRule(ruleId int64) error
	GetRules() map[int64]RuleDescription
}

type RuleDescription

type RuleDescription struct {
	Enabled bool   `json:"enabled"`
	Trigger any    `json:"trigger"`
	Effect  any    `json:"effect"`
	Id      int64  `json:"id"`
	Name    string `json:"name"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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