context

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2019 License: Apache-2.0, Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFactNotFound indicates an error if some fact are not found within the data context.
	ErrFactNotFound = errors.New("Fact not found")
	// ErrFactRetracted indicates an error when a fact were found but it was retracted in the knowledge base.
	ErrFactRetracted = errors.New("Fact is retracted")
)

Functions

This section is empty.

Types

type DataContext

type DataContext struct {
	ObjectStore         map[string]interface{}
	Retracted           []string
	VariableChangeCount uint64
}

DataContext holds all structs instance to be used in rule execution environment.

func NewDataContext

func NewDataContext() *DataContext

NewDataContext will create a new DataContext instance

func (*DataContext) Add

func (ctx *DataContext) Add(key string, obj interface{}) error

Add will add struct instance into rule execution context

func (*DataContext) ExecMethod

func (ctx *DataContext) ExecMethod(methodName string, args []reflect.Value) (reflect.Value, error)

ExecMethod will execute instance member variable using the supplied arguments.

func (*DataContext) GetType

func (ctx *DataContext) GetType(variable string) (reflect.Type, error)

GetType will extract type information of data in this context.

func (*DataContext) GetValue

func (ctx *DataContext) GetValue(variable string) (reflect.Value, error)

GetValue will get member variables Value information. Used by the rule execution to obtain variable value.

func (*DataContext) IsRestracted

func (ctx *DataContext) IsRestracted(key string) bool

IsRestracted checks if a key fact is currently retracted.

func (*DataContext) Reset

func (ctx *DataContext) Reset()

Reset will un-retract all fact, making them available for evaluation and modification.

func (*DataContext) Retract

func (ctx *DataContext) Retract(key string)

Retract temporary retract a fact from data context, making it unavailable for evaluation or modification.

func (*DataContext) SetValue

func (ctx *DataContext) SetValue(variable string, newValue reflect.Value) error

SetValue will set variable value of an object instance in this data context, Used by rule script to set values.

type KnowledgeContext

type KnowledgeContext struct {
}

KnowledgeContext should store the context of knowledge base. for now this context is not yet used.

type RuleContext

type RuleContext struct {
}

RuleContext serve a context information about some rule executions. for now, this rule not yet used.

Jump to

Keyboard shortcuts

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