matchers

package
v5.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MatcherTypeAllKeys string value
	MatcherTypeAllKeys = "ALL_KEYS"
	// MatcherTypeInSegment string value
	MatcherTypeInSegment = "IN_SEGMENT"
	// MatcherTypeWhitelist string value
	MatcherTypeWhitelist = "WHITELIST"
	// MatcherTypeEqualTo string value
	MatcherTypeEqualTo = "EQUAL_TO"
	// MatcherTypeGreaterThanOrEqualTo string value
	MatcherTypeGreaterThanOrEqualTo = "GREATER_THAN_OR_EQUAL_TO"
	// MatcherTypeLessThanOrEqualTo string value
	MatcherTypeLessThanOrEqualTo = "LESS_THAN_OR_EQUAL_TO"
	// MatcherTypeBetween string value
	MatcherTypeBetween = "BETWEEN"
	// MatcherTypeEqualToSet string value
	MatcherTypeEqualToSet = "EQUAL_TO_SET"
	// MatcherTypePartOfSet string value
	MatcherTypePartOfSet = "PART_OF_SET"
	// MatcherTypeContainsAllOfSet string value
	MatcherTypeContainsAllOfSet = "CONTAINS_ALL_OF_SET"
	// MatcherTypeContainsAnyOfSet string value
	MatcherTypeContainsAnyOfSet = "CONTAINS_ANY_OF_SET"
	// MatcherTypeStartsWith string value
	MatcherTypeStartsWith = "STARTS_WITH"
	// MatcherTypeEndsWith string value
	MatcherTypeEndsWith = "ENDS_WITH"
	// MatcherTypeContainsString string value
	MatcherTypeContainsString = "CONTAINS_STRING"
	// MatcherTypeInSplitTreatment string value
	MatcherTypeInSplitTreatment = "IN_SPLIT_TREATMENT"
	// MatcherTypeEqualToBoolean string value
	MatcherTypeEqualToBoolean = "EQUAL_TO_BOOLEAN"
	// MatcherTypeMatchesString string value
	MatcherTypeMatchesString = "MATCHES_STRING"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AllKeysMatcher

type AllKeysMatcher struct {
	Matcher
}

AllKeysMatcher matches any given key and set of attributes

func NewAllKeysMatcher

func NewAllKeysMatcher(negate bool) *AllKeysMatcher

NewAllKeysMatcher returns a pointer to a new instance of AllKeysMatcher

func (AllKeysMatcher) Match

func (m AllKeysMatcher) Match(key string, attributes map[string]interface{}, bucketingKey *string) bool

Match implementation for AllKeysMatcher

type BetweenMatcher

type BetweenMatcher struct {
	Matcher
	ComparisonDataType   string
	LowerComparisonValue int64
	UpperComparisonValue int64
}

BetweenMatcher will match if two numbers or two datetimes are equal

func NewBetweenMatcher

func NewBetweenMatcher(negate bool, lower int64, upper int64, cmpType string, attributeName *string) *BetweenMatcher

NewBetweenMatcher returns a pointer to a new instance of BetweenMatcher

func (*BetweenMatcher) Match

func (m *BetweenMatcher) Match(key string, attributes map[string]interface{}, bucketingKey *string) bool

Match will match if the matchingValue is between lowerComparisonValue and upperComparisonValue

type BooleanMatcher

type BooleanMatcher struct {
	Matcher
	// contains filtered or unexported fields
}

BooleanMatcher returns true if the value supplied can be interpreted as a boolean and is equal to the one stored

func NewBooleanMatcher

func NewBooleanMatcher(negate bool, value *bool, attributeName *string) *BooleanMatcher

NewBooleanMatcher instantiates a new BooleanMatcher

func (*BooleanMatcher) Match

func (m *BooleanMatcher) Match(key string, attributes map[string]interface{}, bucketingKey *string) bool

Match returns true if the value supplied can be interpreted as a boolean and is equal to the one stored

type ContainsAllOfSetMatcher

type ContainsAllOfSetMatcher struct {
	Matcher
	// contains filtered or unexported fields
}

ContainsAllOfSetMatcher matches if the set supplied to the getTreatment is a superset of the one in the feature flag

func NewContainsAllOfSetMatcher

func NewContainsAllOfSetMatcher(negate bool, setItems []string, attributeName *string) *ContainsAllOfSetMatcher

NewContainsAllOfSetMatcher returns a pointer to a new instance of ContainsAllOfSetMatcher

func (*ContainsAllOfSetMatcher) Match

func (m *ContainsAllOfSetMatcher) Match(key string, attributes map[string]interface{}, bucketingKey *string) bool

Match returns true if the set provided is a superset of the one in the feature flag

type ContainsAnyOfSetMatcher

type ContainsAnyOfSetMatcher struct {
	Matcher
	// contains filtered or unexported fields
}

ContainsAnyOfSetMatcher matches if the set supplied to the getTreatment is a superset of the one in the feature flag

func NewContainsAnyOfSetMatcher

func NewContainsAnyOfSetMatcher(negate bool, setItems []string, attributeName *string) *ContainsAnyOfSetMatcher

NewContainsAnyOfSetMatcher returns a pointer to a new instance of ContainsAnyOfSetMatcher

func (*ContainsAnyOfSetMatcher) Match

func (m *ContainsAnyOfSetMatcher) Match(key string, attributes map[string]interface{}, bucketingKey *string) bool

Match returns true if the set provided is a superset of the one in the feature flag

type ContainsStringMatcher

type ContainsStringMatcher struct {
	Matcher
	// contains filtered or unexported fields
}

ContainsStringMatcher matches strings contain one of the substrings in the feature flag

func NewContainsStringMatcher

func NewContainsStringMatcher(negate bool, substrings []string, attributeName *string) *ContainsStringMatcher

NewContainsStringMatcher returns a new instance of ContainsStringMatcher

func (*ContainsStringMatcher) Match

func (m *ContainsStringMatcher) Match(key string, attributes map[string]interface{}, bucketingKey *string) bool

Match returns true if the key contains one of the substrings in the feature flag

type DependencyMatcher

type DependencyMatcher struct {
	Matcher
	// contains filtered or unexported fields
}

DependencyMatcher will match if the evaluation of another split results in one of the treatments defined in the feature flag

func NewDependencyMatcher

func NewDependencyMatcher(negate bool, feature string, treatments []string) *DependencyMatcher

NewDependencyMatcher will return a new instance of DependencyMatcher

func (*DependencyMatcher) Match

func (m *DependencyMatcher) Match(key string, attributes map[string]interface{}, bucketingKey *string) bool

Match will return true if the evaluation of another split results in one of the treatments defined in the feature flag

type EndsWithMatcher

type EndsWithMatcher struct {
	Matcher
	// contains filtered or unexported fields
}

EndsWithMatcher matches strings which end with one of the suffixes in the feature flag

func NewEndsWithMatcher

func NewEndsWithMatcher(negate bool, suffixes []string, attributeName *string) *EndsWithMatcher

NewEndsWithMatcher returns a new instance of EndsWithMatcher

func (*EndsWithMatcher) Match

func (m *EndsWithMatcher) Match(key string, attributes map[string]interface{}, bucketingKey *string) bool

Match returns true if the key provided ends with one of the suffixes in the feature flag.

type EqualToMatcher

type EqualToMatcher struct {
	Matcher
	ComparisonDataType string
	ComparisonValue    int64
}

EqualToMatcher will match if two numbers or two datetimes are equal

func NewEqualToMatcher

func NewEqualToMatcher(negate bool, cmpVal int64, cmpType string, attributeName *string) *EqualToMatcher

NewEqualToMatcher returns a pointer to a new instance of EqualToMatcher

func (*EqualToMatcher) Match

func (m *EqualToMatcher) Match(key string, attributes map[string]interface{}, bucketingKey *string) bool

Match will match if the comparisonValue is equal to the matchingValue

type EqualToSetMatcher

type EqualToSetMatcher struct {
	Matcher
	// contains filtered or unexported fields
}

EqualToSetMatcher matches if the set supplied to the getTreatment is equal to the one in the feature flag

func NewEqualToSetMatcher

func NewEqualToSetMatcher(negate bool, setItems []string, attributeName *string) *EqualToSetMatcher

NewEqualToSetMatcher returns a pointer to a new instance of EqualToSetMatcher

func (*EqualToSetMatcher) Match

func (m *EqualToSetMatcher) Match(key string, attributes map[string]interface{}, bucketingKey *string) bool

Match returns true if the match provided and the one in the feature flag are equal

type GreaterThanOrEqualToMatcher

type GreaterThanOrEqualToMatcher struct {
	Matcher
	ComparisonDataType string
	ComparisonValue    int64
}

GreaterThanOrEqualToMatcher will match if two numbers or two datetimes are equal

func NewGreaterThanOrEqualToMatcher

func NewGreaterThanOrEqualToMatcher(negate bool, cmpVal int64, cmpType string, attributeName *string) *GreaterThanOrEqualToMatcher

NewGreaterThanOrEqualToMatcher returns a pointer to a new instance of GreaterThanOrEqualToMatcher

func (*GreaterThanOrEqualToMatcher) Match

func (m *GreaterThanOrEqualToMatcher) Match(key string, attributes map[string]interface{}, bucketingKey *string) bool

Match will match if the comparisonValue is greater than or equal to the matchingValue

type InSegmentMatcher

type InSegmentMatcher struct {
	Matcher
	// contains filtered or unexported fields
}

InSegmentMatcher matches if the key passed is in the segment which the matcher was constructed with

func NewInSegmentMatcher

func NewInSegmentMatcher(negate bool, segmentName string, attributeName *string) *InSegmentMatcher

NewInSegmentMatcher instantiates a new InSegmentMatcher

func (*InSegmentMatcher) Match

func (m *InSegmentMatcher) Match(key string, attributes map[string]interface{}, bucketingKey *string) bool

Match returns true if the key is in the matcher's segment

type LessThanOrEqualToMatcher

type LessThanOrEqualToMatcher struct {
	Matcher
	ComparisonDataType string
	ComparisonValue    int64
}

LessThanOrEqualToMatcher will match if two numbers or two datetimes are equal

func NewLessThanOrEqualToMatcher

func NewLessThanOrEqualToMatcher(negate bool, cmpVal int64, cmpType string, attributeName *string) *LessThanOrEqualToMatcher

NewLessThanOrEqualToMatcher returns a pointer to a new instance of LessThanOrEqualToMatcher

func (*LessThanOrEqualToMatcher) Match

func (m *LessThanOrEqualToMatcher) Match(key string, attributes map[string]interface{}, bucketingKey *string) bool

Match will match if the comparisonValue is less than or equal to the matchingValue

type Matcher

type Matcher struct {
	*injection.Context
	// contains filtered or unexported fields
}

Matcher struct with added logic that wraps around a DTO

func (*Matcher) Negate

func (m *Matcher) Negate() bool

Negate returns whether this mather is negated or not

type MatcherInterface

type MatcherInterface interface {
	Match(key string, attributes map[string]interface{}, bucketingKey *string) bool
	Negate() bool
	// contains filtered or unexported methods
}

MatcherInterface should be implemented by all matchers

func BuildMatcher

func BuildMatcher(dto *dtos.MatcherDTO, ctx *injection.Context, logger logging.LoggerInterface) (MatcherInterface, error)

BuildMatcher constructs the appropriate matcher based on the MatcherType attribute of the dto

type PartOfSetMatcher

type PartOfSetMatcher struct {
	Matcher
	// contains filtered or unexported fields
}

PartOfSetMatcher matches if the set supplied to the getTreatment is a subset of the one in the feature flag

func NewPartOfSetMatcher

func NewPartOfSetMatcher(negate bool, setItems []string, attributeName *string) *PartOfSetMatcher

NewPartOfSetMatcher returns a pointer to a new instance of PartOfSetMatcher

func (*PartOfSetMatcher) Match

func (m *PartOfSetMatcher) Match(key string, attributes map[string]interface{}, bucketingKey *string) bool

Match returns true if the match provided is a subset of the one in the feature flag

type RegexMatcher

type RegexMatcher struct {
	Matcher
	// contains filtered or unexported fields
}

RegexMatcher matches if the supplied key matches the feature flag's regex

func NewRegexMatcher

func NewRegexMatcher(negate bool, regex string, attributeName *string) *RegexMatcher

NewRegexMatcher returns a new instance to a RegexMatcher

func (*RegexMatcher) Match

func (m *RegexMatcher) Match(key string, attributes map[string]interface{}, bucketingKey *string) bool

Match returns true if the supplied key matches the feature flag's regex

type StartsWithMatcher

type StartsWithMatcher struct {
	Matcher
	// contains filtered or unexported fields
}

StartsWithMatcher matches strings which start with one of the prefixes in the feature flag

func NewStartsWithMatcher

func NewStartsWithMatcher(negate bool, prefixes []string, attributeName *string) *StartsWithMatcher

NewStartsWithMatcher returns a new instance of StartsWithMatcher

func (*StartsWithMatcher) Match

func (m *StartsWithMatcher) Match(key string, attributes map[string]interface{}, bucketingKey *string) bool

Match returns true if the key provided starts with one of the prefixes in the feature flag.

type WhitelistMatcher

type WhitelistMatcher struct {
	Matcher
	// contains filtered or unexported fields
}

WhitelistMatcher matches if the key received is present in the matcher's whitelist

func NewWhitelistMatcher

func NewWhitelistMatcher(negate bool, whitelist []string, attributeName *string) *WhitelistMatcher

NewWhitelistMatcher returns a new WhitelistMatcher

func (*WhitelistMatcher) Match

func (m *WhitelistMatcher) Match(key string, attributes map[string]interface{}, bucketingKey *string) bool

Match returns true if the key is present in the whitelist.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL