Documentation ¶
Overview ¶
Package threshold contains predicates that can define various request thresholds
Examples:
- RequestMethod() == "GET" triggers action when request method equals "GET"
- IsNetworkError() - triggers action on network errors
- RequestMethod() == "GET" && Attempts <= 2 && (IsNetworkError() || ResponseCode() == 408) This predicate triggers for GET requests with maximum 2 attempts on network errors or when upstream returns special http response code 408
Index ¶
- type Predicate
- func AND(fns ...Predicate) Predicate
- func EQ(m interface{}, value interface{}) (Predicate, error)
- func GE(m interface{}, value interface{}) (Predicate, error)
- func GT(m interface{}, value interface{}) (Predicate, error)
- func IsNetworkError() Predicate
- func LE(m interface{}, value interface{}) (Predicate, error)
- func LT(m interface{}, value interface{}) (Predicate, error)
- func NEQ(m interface{}, value interface{}) (Predicate, error)
- func NOT(p Predicate) Predicate
- func OR(fns ...Predicate) Predicate
- func ParseExpression(in string) (Predicate, error)
- type RequestToFloat64
- type RequestToInt
- type RequestToString
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Predicate ¶
Predicate that defines what request can fail over in case of error or http response
func GE ¶
GE returns predicate that tests that value of the mapper function is greater than or equal to the constant
func GT ¶
GT returns predicate that tests that value of the mapper function is greater than the constant
func IsNetworkError ¶
func IsNetworkError() Predicate
IsNetworkError returns a predicate that returns true if last attempt ended with network error.
func LE ¶
LE returns predicate that tests that value of the mapper function is less than or equal to the constant
func LT ¶
LT returns predicate that tests that value of the mapper function is less than the constant
func NEQ ¶
NEQ returns predicate that tests for inequality of the value of the mapper and the constant
func ParseExpression ¶
Parses expression in the go language into Failover predicates
type RequestToFloat64 ¶
RequestToFloat64 defines mapper function that maps a request to some float64 (e.g extracts some ratio)
type RequestToInt ¶
RequestToInt defines mapper function that maps a request to some int (e.g extracts response code)
func Attempts ¶
func Attempts() RequestToInt
Attempts returns mapper of the request to the number of proxy attempts
func ResponseCode ¶
func ResponseCode() RequestToInt
ResponseCode returns mapper of the request to the last response code, returns 0 if there was no response code.
type RequestToString ¶
RequestToString defines mapper function that maps a request to some string (e.g extracts method name)
func RequestMethod ¶
func RequestMethod() RequestToString
RequestMethod returns mapper of the request to its method e.g. POST