Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Rule ¶
type Rule struct {
// TagKey is the HTTP header will be added if rule matched.
TagKey string `yaml:"tagKey"`
// TagValue is the TagKey header's value.
TagValue string `yaml:"tagValue"`
// Description describes the rule.
Description string `yaml:"description"`
// Conditions is the rule's target, it's a conditional expressions beginning with 'if'.
//
// Supports conditional operator:
// ==, !=, >=, <=, >, <, in, mod
// mod is a special keyword which means randomly pick up request according
// to the value in a specified rate. The value after mod op will be set to 0
// if it is < 0. And it will be mod 100 before using it.
// e.g., RealIP mod '10'
//
// Supports logic operator:
// ||, &&, and ()
//
// Supports four types of sources:
// Header, Cookie, Jwt, RealIP
//
// We get Jwt value from HTTP header Authorization,
// by default, Jwt token will be put into this header which has this form:
// Authorization: Bearer <token>.
//
// TODO may support multiple values for on header in future.
//
// e.g.,
// Header.City in 'a, b, c' && (Header.Gender == 'male' || Cookie.UserType == 'VIP')
// || Jwt.key != 'val' || RealIP mod '10'
//
// In practice, there only one legal 'mod', RealIP (TODO supports more approaches).
// And it's better to put RealIP mod <x> in the end, because mod operation need
// to calculate hash, it's much expensive than other condition. If there is
// short circuit, we won't need to do such calculation.
Conditions string `yaml:"conditions"`
// contains filtered or unexported fields
}
Rule is the A/B testing rule specified by user.
Click to show internal directories.
Click to hide internal directories.