import "gopkg.in/src-d/go-vitess.v1/vt/vttablet/tabletserver/rules"
These are actions.
const ( QRNoOp = Operator(iota) QREqual QRNotEqual QRLessThan QRGreaterEqual QRGreaterThan QRLessEqual QRMatch QRNoMatch QRNumOp )
These are comparison operators.
These are return statii.
Action speficies the list of actions to perform when a Rule is triggered.
MarshalJSON marshals to JSON.
type BindVarCond struct {
// contains filtered or unexported fields
}
BindVarCond represents a bind var condition.
func (bvc BindVarCond) MarshalJSON() ([]byte, error)
MarshalJSON marshals to JSON.
type Map struct {
// contains filtered or unexported fields
}
Map is the maintainer of Rules from multiple sources
NewMap returns an empty Map object.
func (qri *Map) FilterByPlan(query string, planid planbuilder.PlanType, tableName string) (newqrs *Rules)
FilterByPlan creates a new Rules by prefiltering on all query rules that are contained in internal Rules structures, in other words, query rules from all predefined sources will be applied.
Get returns the corresponding Rules as designated by ruleSource parameter.
MarshalJSON marshals to JSON.
RegisterSource registers a query rule source name with Map.
SetRules takes an external Rules structure and overwrite one of the internal Rules as designated by ruleSource parameter.
UnRegisterSource removes a registered query rule source name.
Operator represents the list of operators.
MapStrOperator maps a string representation to an Operator.
MarshalJSON marshals to JSON.
Rule represents one rule (conditions-action). Name is meant to uniquely identify a rule. Description is a human readable comment that describes the rule. For a Rule to fire, all conditions of the Rule have to match. For example, an empty Rule will match all requests. Every Rule has an associated Action. If all the conditions of the Rule are met, then the Action is triggerred.
BuildQueryRule builds a query rule from a ruleInfo.
NewQueryRule creates a new Rule.
func (qr *Rule) AddBindVarCond(name string, onAbsent, onMismatch bool, op Operator, value interface{}) error
AddBindVarCond adds a bind variable restriction to the Rule. All bind var conditions have to be satisfied for the Rule to be a match. name represents the name (not regexp) of the bind variable. onAbsent specifies the value of the condition if the bind variable is absent. onMismatch specifies the value of the condition if there's a type mismatch on the condition. For inequalities, the bindvar is the left operand and the value in the condition is the right operand: bindVar Operator value. Value & operator rules Type Operators Bindvar nil "" any type uint64 ==, !=, <, >=, >, <= whole numbers int64 ==, !=, <, >=, >, <= whole numbers string ==, !=, <, >=, >, <=, MATCH, NOMATCH []byte, string whole numbers can be: int, int8, int16, int32, int64, uint64
func (qr *Rule) AddPlanCond(planType planbuilder.PlanType)
AddPlanCond adds to the list of plans that can be matched for the rule to fire. This function acts as an OR: Any plan id match is considered a match.
AddTableCond adds to the list of tableNames that can be matched for the rule to fire. This function acts as an OR: Any tableName match is considered a match.
Copy performs a deep copy of a Rule.
Equal returns true if other is equal to this Rule, otherwise false.
func (qr *Rule) FilterByPlan(query string, planid planbuilder.PlanType, tableName string) (newqr *Rule)
FilterByPlan returns a new Rule if the query and planid match. The new Rule will contain all the original constraints other than the plan and query. If the plan and query don't match the Rule, then it returns nil.
GetAction returns the action for a single rule.
MarshalJSON marshals to JSON.
SetIPCond adds a regular expression condition for the client IP. It has to be a full match (not substring).
SetQueryCond adds a regular expression condition for the query.
SetUserCond adds a regular expression condition for the user name used by the client.
type Rules struct {
// contains filtered or unexported fields
}
Rules is used to store and execute rules for the tabletserver.
New creates a new Rules.
Add adds a Rule to Rules. It does not check for duplicates.
Append merges the rules from another Rules into the receiver
Copy performs a deep copy of Rules. A nil input produces a nil output.
Delete deletes a Rule by name and returns the rule that was deleted. It returns nil if the rule was not found.
Equal returns true if other is equal to this object, otherwise false.
func (qrs *Rules) FilterByPlan(query string, planid planbuilder.PlanType, tableName string) (newqrs *Rules)
FilterByPlan creates a new Rules by prefiltering on the query and planId. This allows us to create query plan specific Rules out of the original Rules. In the new rules, query, plans and tableNames predicates are empty.
Find finds the first occurrence of a Rule by matching the Name field. It returns nil if the rule was not found.
func (qrs *Rules) GetAction(ip, user string, bindVars map[string]*querypb.BindVariable) (action Action, desc string)
GetAction runs the input against the rules engine and returns the action to be performed.
MarshalJSON marshals to JSON.
UnmarshalJSON unmarshals Rules.
Package rules imports 14 packages (graph) and is imported by 3 packages. Updated 2019-06-13. Refresh now. Tools for package owners.