Exemplo n.º 1
0
// Evaluate a given expression as a boolean predicate against a set of fields and tags
func EvalPredicate(se *tick.StatefulExpr, now time.Time, fields models.Fields, tags models.Tags) (bool, error) {
	vars, err := mergeFieldsAndTags(now, fields, tags)
	if err != nil {
		return false, err
	}
	b, err := se.EvalBool(vars)
	if err != nil {
		return false, err
	}
	return b, nil
}
Exemplo n.º 2
0
// Evaluate a given expression as a boolean predicate against a set of fields and tags
func EvalPredicate(se *tick.StatefulExpr, fields models.Fields, tags map[string]string) (bool, error) {
	vars, err := mergeFieldsAndTags(fields, tags)
	if err != nil {
		return false, err
	}
	b, err := se.EvalBool(vars)
	if err != nil {
		return false, err
	}
	return b, nil
}