Documentation ¶
Overview ¶
Package expression provides support for evaluating expressions in Aptomi, with support for caching compiled expressions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a thread-safe cache of compiled expressions
func (*Cache) EvaluateAsBool ¶
func (cache *Cache) EvaluateAsBool(expressionStr string, params *Parameters) (bool, error)
EvaluateAsBool evaluates boolean expression given a set of parameters. If an compiled expression already exists in cache, it will be used. Otherwise it will get compiled and added to the cache before evaluating the expression. This method is thread-safe and can be called concurrently from multiple goroutines.
type Expression ¶
type Expression struct {
// contains filtered or unexported fields
}
Expression struct contains expression string as well as its compiled version
func NewExpression ¶
func NewExpression(expressionStr string) (*Expression, error)
NewExpression compiles an expression and returns the result in Expression struct Parameter expressionStr must follow syntax defined by https://github.com/Knetic/govaluate
func (*Expression) EvaluateAsBool ¶
func (expression *Expression) EvaluateAsBool(params *Parameters) (bool, error)
EvaluateAsBool evaluates a compiled boolean expression given a set of named parameters
type Parameters ¶
type Parameters map[string]interface{}
Parameters is a set of named parameters for the expression