actor

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: GPL-3.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(x, y interface{}, operator string) (bool, error)

func New

func New() chik.Handler

New creates a new actor handler

func StringInterfaceToStateQuery

func StringInterfaceToStateQuery(sourceType, targetType reflect.Type, sourceData interface{}) (interface{}, error)

Types

type Action

type Action struct {
	ID      string           `json:"id"`
	Query   StateQueries     `json:"query,omitempty"`
	Perform []*types.Command `json:"perform,omitempty"`
}

Action is composed of a list of Queries and a Command to perform in case the AND composition of queries returns true

type ActionCommand added in v1.6.0

type ActionCommand struct {
	Action types.Action `json:"action" mapstructure:"action"`
	Value  Action       `json:"value,omitempty" mapstructure:"value"`
}

type MixedQuery

type MixedQuery struct {
	Var1      string      `json:"var1"`
	Op        string      `json:"op"`
	Const     interface{} `json:"const"`
	Detrigger bool        `json:"disable_trigger_on_change,omitempty"`
}

MixedQuery compares an element of State.Current with a constant only if that element is different from the same in State.Previous

func (*MixedQuery) Execute

func (q *MixedQuery) Execute(state *State) (res QueryResult, err error)

type QueryResult added in v1.4.0

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

type State

type State struct {
	Current  map[string]interface{} `json:"current"`
	Previous map[string]interface{} `json:"previous"`
	// contains filtered or unexported fields
}

func CreateState added in v1.8.0

func CreateState(previous, current map[string]interface{}) *State

func (*State) GetFieldDescriptor added in v1.4.0

func (s *State) GetFieldDescriptor(key string) (*fieldDescriptor, error)

type StateQueries added in v1.6.0

type StateQueries []StateQuery

func (*StateQueries) UnmarshalJSON added in v1.6.0

func (sq *StateQueries) UnmarshalJSON(data []byte) error

type StateQuery

type StateQuery interface {
	Execute(state *State) (QueryResult, error)
}

type StructQuery

type StructQuery struct {
	Var1      string `json:"var1"`
	Op        string `json:"op"`
	Var2      string `json:"var2"`
	Detrigger bool   `json:"disable_trigger_on_change,omitempty"`
}

StructQuery compares two elements of the State oin every state change

func (*StructQuery) Execute

func (q *StructQuery) Execute(state *State) (res QueryResult, err error)

Jump to

Keyboard shortcuts

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