ecarule

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package ecarule defines GoAbU ECA rules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	// Assignment is a simple assignment to Resource's variable. The expression contains only local resources.
	Assignment *ast.Assignment
	// Resource is the name of the resource in the L-value of Assignment.
	Resource string
}

Action groups an assignment with the name of the involved resource.

func (Action) String

func (a Action) String() string

String returns the code of the action's assignment.

type LocalTask added in v0.5.0

type LocalTask struct {
	// Condition is an expression with boolean result indicating whether the activated rule is to be evaluated.
	Condition *ast.Expression
	// Actions is a list of assignments where only local resources can appear.
	Actions []Action
}

LocalTask models a local task allowed to modify only local resources.

type Parser added in v0.4.0

type Parser interface {
	// Parse parses a series of GoAbU rules.
	Parse(...string) ([]Rule, []error)
	// ParseExpressions parses a series of local expressions.
	ParseExpressions(...string) ([]*ast.Expression, []error)
	// ParseActions parses a series of local actions.
	ParseActions(string) ([]Action, []error)
	// ParseRemoteTasks parses a series of received tasks into local tasks that can be executed.
	ParseRemoteTasks(map[string]string, ...RemoteTask) ([]LocalTask, []error)
}

Parser is the interface implemented by parsers of GoAbU rules.

type RemoteTask added in v0.5.0

type RemoteTask struct {
	// Condition encodes the rule's condition.
	Condition string
	// Actions encodes the actions that are to be performed.
	Actions []string
	// RemoteResources contains all the names of the remote resources of the task.
	RemoteResources []string
	// LocalResources contains all the names of the local resources of the task.
	LocalResources []string
}

RemoteTask models a remote task that can update the resources of the other nodes. In remote tasks, remote resources are prefixed with "this." while the local resources are prefixed with "ext.".

type Rule

type Rule struct {
	// Name specifies the rule's name.
	Name string
	// Events is a list of resource names. The rule is activated when any of the listed resources changes its value.
	Events []string
	// LocalTasks contains the rule's local tasks that can modify only local resources when the condition matches.
	LocalTasks []LocalTask
	// RemoteTasks contains the rule's remote tasks that modify the resources of the other nodes matching the condition.
	RemoteTasks []RemoteTask
}

Rule models a GoAbU (Event-Condition-Action) rule.

type RuleDict

type RuleDict map[string]*Rule

func MakeRuleDict

func MakeRuleDict() RuleDict

func (RuleDict) Add

func (dst RuleDict) Add(src RuleDict)

Precondition: dst != nil

func (RuleDict) Empty

func (rules RuleDict) Empty() bool

func (RuleDict) Has

func (rules RuleDict) Has(name string) bool

func (RuleDict) Insert

func (rules RuleDict) Insert(rule *Rule)

Precondition: rules != nil

Jump to

Keyboard shortcuts

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