Documentation
¶
Overview ¶
*
- Copyright 2022 Comcast Cable Communications Management, LLC *
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License. *
- SPDX-License-Identifier: Apache-2.0
*
- Copyright 2022 Comcast Cable Communications Management, LLC *
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License. *
- SPDX-License-Identifier: Apache-2.0
*
- Copyright 2022 Comcast Cable Communications Management, LLC *
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License. *
- SPDX-License-Identifier: Apache-2.0
*
- Copyright 2022 Comcast Cable Communications Management, LLC *
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License. *
- SPDX-License-Identifier: Apache-2.0
*
- Copyright 2022 Comcast Cable Communications Management, LLC *
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License. *
- SPDX-License-Identifier: Apache-2.0
*
- Copyright 2022 Comcast Cable Communications Management, LLC *
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License. *
- SPDX-License-Identifier: Apache-2.0
*
- Copyright 2022 Comcast Cable Communications Management, LLC *
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License. *
- SPDX-License-Identifier: Apache-2.0
*
- Copyright 2022 Comcast Cable Communications Management, LLC *
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License. *
- SPDX-License-Identifier: Apache-2.0
*
- Copyright 2022 Comcast Cable Communications Management, LLC *
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License. *
- SPDX-License-Identifier: Apache-2.0
*
- Copyright 2022 Comcast Cable Communications Management, LLC *
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License. *
- SPDX-License-Identifier: Apache-2.0
*
- Copyright 2022 Comcast Cable Communications Management, LLC *
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License. *
- SPDX-License-Identifier: Apache-2.0
*
- Copyright 2022 Comcast Cable Communications Management, LLC *
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License. *
- SPDX-License-Identifier: Apache-2.0
*
- Copyright 2022 Comcast Cable Communications Management, LLC *
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License. *
- SPDX-License-Identifier: Apache-2.0
*
- Copyright 2022 Comcast Cable Communications Management, LLC *
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License. *
- SPDX-License-Identifier: Apache-2.0
*
- Copyright 2022 Comcast Cable Communications Management, LLC *
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at *
- http://www.apache.org/licenses/LICENSE-2.0 *
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License. *
- SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- Variables
- func ChangeFixedArgToNewValue(oldFixedArgValue string, newFixedArgValue string, rule Rule, operation string) bool
- func CheckFreeArgExists2(conditionInfos []ConditionInfo, freeArg FreeArg) error
- func CheckFreeArgExists3(conditionInfos []ConditionInfo, freeArg FreeArg, operation string) error
- func CompareRules(r1 Rule, r2 Rule) int
- func ConditionHasEmptyElements(rule Rule) bool
- func EqualComplexRules(rule1 *Rule, rule2 *Rule) bool
- func FitsPercent(itf interface{}, percent float64) bool
- func FreeArgExists(conditionInfos []ConditionInfo, freeArg FreeArg) bool
- func FreeArgExists2(conditionInfos []ConditionInfo, freeArg FreeArg, operation string) bool
- func GetDuplicateFixedArgListItems(fixedArg FixedArg) (retList []string)
- func GetFixedArgFromConditionByFreeArgAndOperation(condition Condition, freeArg string, operation string) interface{}
- func GetFixedArgFromConditionByOperation(condition *Condition, operation string) interface{}
- func GetFixedArgsFromRuleByFreeArgAndOperation(rule Rule, freeArg string, operation string) []string
- func GetFixedArgsFromRuleByOperation(rule *Rule, operation string) []string
- func IsExistConditionByFixedArgValue(rule Rule, fixedArgValue string) bool
- func IsExistConditionByFreeArgAndFixedArg(rule *Rule, freeArg string, fixedArg string) bool
- func IsExistConditionByFreeArgName(rule Rule, freeArgName string) bool
- func IsExistPartOfSearchValueInFixedArgs(fixedArgs *Collection, searchValue string) bool
- func NormalizeCondition(condition *Condition) error
- func NormalizeConditions(rule *Rule) error
- func RemElemFromRuleList(rules []*Rule) (*Rule, []*Rule)
- type BaseEvaluator
- type BaseTimeEvaluator
- type Bean
- type Collection
- type ComparingEvaluator
- type Condition
- func GetDuplicateConditions(conditions []Condition) (result []Condition)
- func GetDuplicateConditionsBetweenOR(rule Rule) (result []Condition)
- func GetDuplicateConditionsForAdmin(conditions []Condition) (result []Condition)
- func GetDuplicateConditionsFromRule(rule Rule) (result []Condition)
- func NewCondition(freeArg *FreeArg, operation string, fixedArg *FixedArg) *Condition
- func ToConditions(rule *Rule) []*Condition
- func (c *Condition) Copy() *Condition
- func (c *Condition) Equals(x *Condition) bool
- func (c *Condition) GetFixedArg() *FixedArg
- func (c *Condition) GetFreeArg() *FreeArg
- func (c *Condition) GetOperation() string
- func (c *Condition) MarshalJSON() ([]byte, error)
- func (c *Condition) SetFixedArg(fixedArg *FixedArg)
- func (c *Condition) SetFreeArg(freeArg *FreeArg)
- func (c *Condition) SetOperation(operation string)
- func (c *Condition) String() string
- type ConditionInfo
- type FixedArg
- func (a *FixedArg) Copy() *FixedArg
- func (a *FixedArg) Equals(x *FixedArg) bool
- func (a *FixedArg) GetValue() interface{}
- func (a *FixedArg) IsCollectionValue() bool
- func (a *FixedArg) IsDoubleValue() bool
- func (a *FixedArg) IsStringValue() bool
- func (a *FixedArg) IsValid() bool
- func (a *FixedArg) String() string
- type FnEvaluateInternal
- type FnEvaluation
- type FnIntEval
- type FreeArg
- type IConditionEvaluator
- type IpAddressEvaluator
- type Parser
- type Rule
- func (r *Rule) AddCompoundPart(rule Rule)
- func (r *Rule) Equals(x *Rule) bool
- func (r *Rule) GetCompoundParts() []Rule
- func (r *Rule) GetCondition() *Condition
- func (r *Rule) GetFreeArg() *FreeArg
- func (r *Rule) GetInListNames() []string
- func (r *Rule) GetRelation() string
- func (r *Rule) GetTree() string
- func (r *Rule) Id() string
- func (r *Rule) IsCompound() bool
- func (r *Rule) IsCompoundPartsEmpty() bool
- func (r *Rule) IsEmpty() bool
- func (r *Rule) IsNegated() bool
- func (r *Rule) SetCompoundParts(compoundParts []Rule)
- func (r *Rule) SetCondition(condition *Condition)
- func (r *Rule) SetId(xxid string)
- func (r *Rule) SetNegated(negated bool)
- func (r *Rule) SetRelation(relation string)
- func (r *Rule) String() string
- type RuleProcessor
- func (p *RuleProcessor) AddEvaluators(evs []IConditionEvaluator)
- func (p *RuleProcessor) Evaluate(r *Rule, context map[string]string, fields log.Fields, vargNegations ...bool) bool
- func (p *RuleProcessor) EvaluateTest(r *Rule, context map[string]string, fields log.Fields, vargNegations ...bool) bool
- func (p *RuleProcessor) Filter(rules []Rule, context map[string]string) []Rule
- func (p *RuleProcessor) GetEvaluatorOK(r *Rule) bool
- func (p *RuleProcessor) Size() int
- type RuleProcessorFactory
- type Value
- type XRule
Constants ¶
View Source
const ( StandardFreeArgTypeString = "STRING" StandardFreeArgTypeLong = "LONG" StandardFreeArgTypeVoid = "VOID" StandardFreeArgTypeAny = "ANY" StandardOperationIs = "IS" StandardOperationGt = "GT" StandardOperationGte = "GTE" StandardOperationLt = "LT" StandardOperationLte = "LTE" StandardOperationLike = "LIKE" StandardOperationIn = "IN" StandardOperationAnyMatched = "ANY_MATCHED" StandardOperationPercent = "PERCENT" StandardOperationExists = "EXISTS" StandardOperationInList = "IN_LIST" StandardOperationMatch = "MATCH" StandardOperationRange = "RANGE" AuxFreeArgTypeTime = "TIME" AuxFreeArgTypeIpAddress = "IP_ADDRESS" AuxFreeArgTypeMacAddress = "MAC_ADDRESS" RelationOr = "OR" RelationAnd = "AND" )
View Source
const ( LeftParan = "(" RightParan = ")" SpaceChar = " " )
Variables ¶
View Source
var SipHashKey = [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
View Source
var UseMap bool
Functions ¶
func CheckFreeArgExists2 ¶
func CheckFreeArgExists2(conditionInfos []ConditionInfo, freeArg FreeArg) error
func CheckFreeArgExists3 ¶
func CheckFreeArgExists3(conditionInfos []ConditionInfo, freeArg FreeArg, operation string) error
func CompareRules ¶
*
- provides compareTo implementation compatible with {@code java.util.Comparator<Rule>}
- that can be used for rule ordering since it takes into account both rule
- and priority of operations (ascending PERCENT < LIKE < IN < IS) *
- @param r1 first rule to compare
- @param r2 second rule to compare
- @return comparison result according to {@link java.util.Comparator#compare(Object, Object)}
func EqualComplexRules ¶
func FitsPercent ¶
func FreeArgExists ¶
func FreeArgExists(conditionInfos []ConditionInfo, freeArg FreeArg) bool
func FreeArgExists2 ¶
func FreeArgExists2(conditionInfos []ConditionInfo, freeArg FreeArg, operation string) bool
func IsExistPartOfSearchValueInFixedArgs ¶
func IsExistPartOfSearchValueInFixedArgs(fixedArgs *Collection, searchValue string) bool
func NormalizeCondition ¶
func NormalizeConditions ¶
func RemElemFromRuleList ¶
RemElemFromRuleList ... remove / popup a element from slice
Types ¶
type BaseEvaluator ¶
type BaseEvaluator struct {
// contains filtered or unexported fields
}
func NewBaseEvaluator ¶
func NewBaseEvaluator(freeArgType string, operation string, evaluateInternal FnEvaluateInternal) *BaseEvaluator
func (*BaseEvaluator) Evaluate ¶
func (e *BaseEvaluator) Evaluate(condition *Condition, context map[string]string) bool
func (*BaseEvaluator) FreeArgType ¶
func (e *BaseEvaluator) FreeArgType() string
func (*BaseEvaluator) Operation ¶
func (e *BaseEvaluator) Operation() string
func (*BaseEvaluator) Validate ¶
func (e *BaseEvaluator) Validate(fixedArg *FixedArg) error
TODO eval if this is necessary
type BaseTimeEvaluator ¶
type BaseTimeEvaluator struct {
// contains filtered or unexported fields
}
func NewBaseTimeEvaluator ¶
func NewBaseTimeEvaluator(freeArgType string, operation string, fn FnIntEval) *BaseTimeEvaluator
func (*BaseTimeEvaluator) Evaluate ¶
func (e *BaseTimeEvaluator) Evaluate(c *Condition, context map[string]string) bool
func (*BaseTimeEvaluator) FreeArgType ¶
func (e *BaseTimeEvaluator) FreeArgType() string
func (*BaseTimeEvaluator) Operation ¶
func (e *BaseTimeEvaluator) Operation() string
type Collection ¶
type Collection struct {
// Cannot specify omitempty for this field otherwise XConf Java will not be able to deserialize the JSON
Value []string `json:"value"`
}
func (*Collection) MarshalJSON ¶
func (c *Collection) MarshalJSON() ([]byte, error)
type ComparingEvaluator ¶
type ComparingEvaluator struct {
// contains filtered or unexported fields
}
func NewComparingEvaluator ¶
func NewComparingEvaluator(freeArgType string, operation string, fn FnEvaluation) *ComparingEvaluator
func (*ComparingEvaluator) Evaluate ¶
func (e *ComparingEvaluator) Evaluate(condition *Condition, context map[string]string) bool
func (*ComparingEvaluator) FreeArgType ¶
func (e *ComparingEvaluator) FreeArgType() string
func (*ComparingEvaluator) Operation ¶
func (e *ComparingEvaluator) Operation() string
type Condition ¶
type Condition struct {
FreeArg *FreeArg `json:"freeArg"`
Operation string `json:"operation"`
FixedArg *FixedArg `json:"fixedArg"`
}
func GetDuplicateConditions ¶
func NewCondition ¶
func ToConditions ¶
func (*Condition) GetFixedArg ¶
func (*Condition) GetFreeArg ¶
func (*Condition) GetOperation ¶
func (*Condition) MarshalJSON ¶
func (*Condition) SetFixedArg ¶
func (*Condition) SetFreeArg ¶
func (*Condition) SetOperation ¶
type ConditionInfo ¶
ConditionInfo is ...
func GetConditionInfos ¶
func GetConditionInfos(conditions []*Condition) (result []ConditionInfo)
func NewConditionInfo ¶
func NewConditionInfo(freeArg FreeArg, operation string) *ConditionInfo
NewConditionInfo create a new instance
type FixedArg ¶
type FixedArg struct {
Bean *Bean `json:"bean,omitempty"`
Collection *Collection `json:"collection,omitempty"`
}
func NewFixedArg ¶
func NewFixedArg(itf interface{}) *FixedArg
func (*FixedArg) IsCollectionValue ¶
func (*FixedArg) IsDoubleValue ¶
func (*FixedArg) IsStringValue ¶
type FnEvaluateInternal ¶
type FnEvaluation ¶
type FnIntEval ¶
NOTE:
The development of this function is postponed because I think this type is not used in the current prod/ci data set.
type FreeArg ¶
func NewFreeArg ¶
type IConditionEvaluator ¶
type IConditionEvaluator interface {
Evaluate(*Condition, map[string]string) bool
FreeArgType() string
Operation() string
}
func GetAuxEvaluators ¶
func GetAuxEvaluators() []IConditionEvaluator
func GetComparingEvaluators ¶
func GetComparingEvaluators(freeArgType string) []IConditionEvaluator
func GetStandardEvaluators ¶
func GetStandardEvaluators() []IConditionEvaluator
type IpAddressEvaluator ¶
type IpAddressEvaluator struct {
// contains filtered or unexported fields
}
func NewIpAddressEvaluator ¶
func NewIpAddressEvaluator(freeArgType string, operation string, nsListDao db.CachedSimpleDao) *IpAddressEvaluator
func (*IpAddressEvaluator) Evaluate ¶
func (e *IpAddressEvaluator) Evaluate(condition *Condition, context map[string]string) bool
func (*IpAddressEvaluator) FreeArgType ¶
func (e *IpAddressEvaluator) FreeArgType() string
func (*IpAddressEvaluator) Operation ¶
func (e *IpAddressEvaluator) Operation() string
type Rule ¶
type Rule struct {
CompoundParts []Rule `json:"compoundParts,omitempty"`
Condition *Condition `json:"condition,omitempty"`
Negated bool `json:"negated"`
Relation string `json:"relation,omitempty"`
Xxid string `json:"xxid,omitempty"` // temp use for testing
}
func FlattenRule ¶
func NewEmptyRule ¶
func NewEmptyRule() *Rule
func (*Rule) AddCompoundPart ¶
func (*Rule) GetCompoundParts ¶
func (*Rule) GetCondition ¶
func (*Rule) GetFreeArg ¶
func (*Rule) GetInListNames ¶
func (*Rule) GetRelation ¶
func (*Rule) IsCompound ¶
func (*Rule) IsCompoundPartsEmpty ¶
func (*Rule) SetCompoundParts ¶
func (*Rule) SetCondition ¶
func (*Rule) SetNegated ¶
func (*Rule) SetRelation ¶
type RuleProcessor ¶
type RuleProcessor struct {
// contains filtered or unexported fields
}
func NewRuleProcessor ¶
func NewRuleProcessor() *RuleProcessor
func (*RuleProcessor) AddEvaluators ¶
func (p *RuleProcessor) AddEvaluators(evs []IConditionEvaluator)
func (*RuleProcessor) EvaluateTest ¶
func (*RuleProcessor) Filter ¶
func (p *RuleProcessor) Filter(rules []Rule, context map[string]string) []Rule
func (*RuleProcessor) GetEvaluatorOK ¶
func (p *RuleProcessor) GetEvaluatorOK(r *Rule) bool
func (*RuleProcessor) Size ¶
func (p *RuleProcessor) Size() int
type RuleProcessorFactory ¶
type RuleProcessorFactory struct {
Processor *RuleProcessor
}
func NewRuleProcessorFactory ¶
func NewRuleProcessorFactory() *RuleProcessorFactory
func (*RuleProcessorFactory) RuleProcessor ¶
func (f *RuleProcessorFactory) RuleProcessor() *RuleProcessor
Click to show internal directories.
Click to hide internal directories.