Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var TypeNames = map[Type]string{
TypeValue: "comparison_value",
TypePercentage: "comparison_percentage",
}
TypeNames maps a comparison.Type to its string form.
Functions ¶
This section is empty.
Types ¶
type Comparator ¶
Comparator is an interface that all comparators must implement
type Eq ¶
type Eq struct { }
Eq implements an "equal" comparator
type Expression ¶
type Expression struct { Type Type Cmp Comparator RHS float64 // contains filtered or unexported fields }
Expression is a struct that represents the deserialization of a string expression. The deserialization includes the following: * The comparison type (absolute, relative) * The comparison function and operator * The right hand side operator
func ParseExpression ¶
func ParseExpression(expression string) (*Expression, error)
ParseExpression deserializes a string comparison expression (e.g. "">=50") into a Expression object. Returns an error if the expression is not supported.
func (Expression) EvaluateSuccess ¶
func (e Expression) EvaluateSuccess(success, total uint64) (*Result, error)
EvaluateSuccess invokes the Compare function of the internal Comparator object
func (Expression) String ¶
func (e Expression) String() string
type Ge ¶
type Ge struct { }
Ge implements a "greater or equal" comparator
type Gt ¶
type Gt struct { }
Gt implements a "greater than" comparator
type Le ¶
type Le struct { }
Le implements a "less or equal" comparator
type Lt ¶
type Lt struct { }
Lt implements a "less than" comparator
type Operator ¶
type Operator string
Operator is the string representation of any of the supported comparison operators
type Result ¶
Result wraps the result of a comparison, including the full expression that was evaluated