Documentation ¶
Overview ¶
Package interpreter processes the queries and evaluates them
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrSyntaxError when a syntax error is detected ErrSyntaxError = errors.New("syntax error") // ErrUnsupportedFeature when an expression or attribute type in not yet supported by the interpreter ErrUnsupportedFeature = errors.New("unsupported expression or attribute type") )
Functions ¶
This section is empty.
Types ¶
type ExpressionType ¶
type ExpressionType string
ExpressionType type of the evaluated expression
const ( // ExpressionTypeKey expression used to evalute primary key values ExpressionTypeKey ExpressionType = "key" // ExpressionTypeFilter expression used to filter items ExpressionTypeFilter ExpressionType = "filter" // ExpressionTypeConditional expression used for conditional writes ExpressionTypeConditional ExpressionType = "conditional" )
type Interpreter ¶
type Interpreter interface { Match(input MatchInput) (bool, error) Update(input UpdateInput) error }
Interpreter types expression interpreter interface
type Language ¶
type Language struct {
Debug bool
}
Language interpreter
func (*Language) Match ¶
func (li *Language) Match(input MatchInput) (bool, error)
Match evalute the item with given expression and attributes
func (*Language) Update ¶
func (li *Language) Update(input UpdateInput) error
Update change the item with given expression and attributes
type MatchInput ¶
type MatchInput struct { TableName string Expression string ExpressionType ExpressionType Item map[string]*types.Item Attributes map[string]*types.Item Aliases map[string]string }
MatchInput parameters to use match function
type MatcherFunc ¶
MatcherFunc function used to filter data
type Native ¶
type Native struct {
// contains filtered or unexported fields
}
Native simple interpreter using pure go functions
func NewNativeInterpreter ¶
func NewNativeInterpreter() *Native
NewNativeInterpreter returns a new native interpreter
func (*Native) AddMatcher ¶
func (ni *Native) AddMatcher(tablename string, t ExpressionType, expr string, matcher MatcherFunc)
AddMatcher add expression matcher to use on key or filter queries
func (*Native) AddUpdater ¶
func (ni *Native) AddUpdater(tablename string, expr string, updater UpdaterFunc)
AddUpdater add expression updater to use on key or filter queries
func (*Native) Match ¶
func (ni *Native) Match(input MatchInput) (bool, error)
Match evalute the item with given expression and attributes
func (*Native) Update ¶
func (ni *Native) Update(input UpdateInput) error
Update change the item with given expression and attributes