evaluator

package
v0.0.0-...-a1f2fe4 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2017 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCacheSize = 1024

DefaultCacheSize is the default size for the expression cache.

View Source
const DefaultMaxStringTableSizeForPurge = 1024

DefaultMaxStringTableSizeForPurge is the default value for

Variables

This section is empty.

Functions

func NewTypeChecker

func NewTypeChecker() expr.TypeChecker

NewTypeChecker returns a new TypeChecker implementation.

Types

type IL

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

IL is an implementation of expr.Evaluator that also exposes specific methods. Specifically, it can listen to config change events.

func NewILEvaluator

func NewILEvaluator(cacheSize int, maxStringTableSizeForPurge int) (*IL, error)

NewILEvaluator returns a new instance of IL.

func (*IL) AssertType

func (e *IL) AssertType(expr string, finder expr.AttributeDescriptorFinder, expectedType pb.ValueType) error

AssertType evaluates the type of expr using the attribute set; if the evaluated type is equal to the expected type we return nil, and return an error otherwise.

func (*IL) ChangeVocabulary

func (e *IL) ChangeVocabulary(finder expr.AttributeDescriptorFinder)

ChangeVocabulary handles changing of the attribute vocabulary.

func (*IL) ConfigChange

func (e *IL) ConfigChange(cfg config.Resolver, df descriptor.Finder, handlers map[string]*config.HandlerInfo)

ConfigChange handles changing of configuration.

func (*IL) Eval

func (e *IL) Eval(expr string, attrs attribute.Bag) (interface{}, error)

Eval evaluates expr using the attr attribute bag and returns the result as interface{}.

func (*IL) EvalPredicate

func (e *IL) EvalPredicate(expr string, attrs attribute.Bag) (bool, error)

EvalPredicate evaluates expr using the attr attribute bag and returns the result as bool.

func (*IL) EvalString

func (e *IL) EvalString(expr string, attrs attribute.Bag) (string, error)

EvalString evaluates expr using the attr attribute bag and returns the result as string.

func (*IL) EvalType

func (e *IL) EvalType(expression string, finder expr.AttributeDescriptorFinder) (pb.ValueType, error)

EvalType evaluates expr using the attr attribute bag and returns the type of the result.

Jump to

Keyboard shortcuts

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