engine

package
v0.0.0-...-869876a Latest Latest
Warning

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

Go to latest
Published: May 26, 2014 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

action

engine document

expression.go

notification.go

operators

rulejson.go

Index

Constants

View Source
const (
	SMS = ActionType(iota + 1)
	EMAIL
	UPDATE
	HTTP
)

QUE TODO VAYA POR HTTP CON DIFERENTES PLANTILLAS INTERNAS?????

View Source
const (
	EQ = Op(iota + 1)
	NE
	LT
	GT
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action interface {
	Do(n *Notif) error
}

func NewAction

func NewAction(actionType ActionType, templateString string, parameters map[string]string) (axn Action, err error)

type ActionData

type ActionData struct {
	Type         ActionType
	TemplateText string
	Parameters   map[string]string
	// contains filtered or unexported fields
}

type ActionJSON

type ActionJSON struct {
	Type       string            `json:"type"`
	Template   string            `json:"template"`
	Parameters map[string]string `json:"params"`
}

type ActionType

type ActionType int

func ParseActionType

func ParseActionType(s string) (at ActionType, err error)

func (ActionType) String

func (t ActionType) String() string

type CondJSON

type CondJSON struct {
	Type string         `json:"type"`
	Expr [3]interface{} `json:"expr"`
}

type Condition

type Condition struct {
	Op       Op
	Exp1     Expression
	Exp2     Expression
	IsNumber bool
}

func (*Condition) Matched

func (c *Condition) Matched(n *Notif) (matched bool, err error)

type EmailAction

type EmailAction struct {
	*ActionData
}

func (*EmailAction) Do

func (a *EmailAction) Do(n *Notif) error

type Engine

type Engine struct {
	Rules []*Rule //Too simple, better data structure is required. Only for starting
	sync.RWMutex
}

func (*Engine) AddRule

func (e *Engine) AddRule(r *Rule) (err error)

func (*Engine) Process

func (e *Engine) Process(n *Notif) (err error)

type Expression

type Expression struct {
	Reference string
	Text      string
	Number    float64
}

type HTTPAction

type HTTPAction struct {
	*ActionData
}

func (*HTTPAction) Do

func (a *HTTPAction) Do(n *Notif) error

type Notif

type Notif struct {
	ID       string
	Received time.Time
	Data     map[string]interface{}
}

func NewNotif

func NewNotif(data []byte) (n *Notif, err error)

func (*Notif) GetNumber

func (n *Notif) GetNumber(exp string) (number float64, err error)

func (*Notif) GetString

func (n *Notif) GetString(exp string) (str string, err error)

type Op

type Op int

func (Op) String

func (o Op) String() string

type Rule

type Rule struct {
	ID     string
	Conds  []Condition
	Action Action
}

func NewRule

func NewRule(body []byte) (r *Rule, err error)

func (*Rule) Do

func (r *Rule) Do(n *Notif) (err error)

func (*Rule) Matched

func (r *Rule) Matched(n *Notif) (matched bool, err error)

type RuleJSON

type RuleJSON struct {
	And    []CondJSON `json:"and"`
	Action ActionJSON `json:"axn"`
}

func ParseRuleJSON

func ParseRuleJSON(data []byte) (rj *RuleJSON, err error)

func (*RuleJSON) Rule

func (rj *RuleJSON) Rule() (pr *Rule, err error)

type SMSAction

type SMSAction struct {
	*ActionData
}

func (*SMSAction) Do

func (a *SMSAction) Do(n *Notif) (err error)

type UpdateAction

type UpdateAction struct {
	*ActionData
}

func (*UpdateAction) Do

func (a *UpdateAction) Do(n *Notif) error

Jump to

Keyboard shortcuts

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