selector

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EqualOperator    = "="
	NotEqualOperator = "!="
)

Variables

This section is empty.

Functions

func Match

func Match(fieldSelectorStr string, content interface{}, rules map[string]map[string]FieldSelector) (bool, error)

Types

type BoolSelector

type BoolSelector struct {
	// contains filtered or unexported fields
}

func NewBoolSelector

func NewBoolSelector(field string, matchMode SelectorOperatorSymbol) *BoolSelector

func (*BoolSelector) Eq

func (s *BoolSelector) Eq(value reflect.Value, matchValue string) (bool, error)

func (*BoolSelector) GetField

func (s *BoolSelector) GetField() string

func (*BoolSelector) GetMatchFunc

func (s *BoolSelector) GetMatchFunc(operatorSymbol string) (MatchFunc, error)

func (*BoolSelector) NotEq

func (s *BoolSelector) NotEq(value reflect.Value, matchValue string) (bool, error)

type FieldSelector

type FieldSelector interface {
	GetField() string
	GetMatchFunc(operatorSymbol string) (MatchFunc, error)
}

type FieldType

type FieldType int

type Filter

type Filter struct {
	Field  string
	Value  string
	Symbol string
	MatchFunc
}

func ParseFilterFieldString

func ParseFilterFieldString(fieldSelectorStr string) (filters []*Filter, err error)

type MatchFunc

type MatchFunc func(value reflect.Value, matchValue string) (bool, error)

type SelectorOperatorSymbol

type SelectorOperatorSymbol string
const (
	Eq    SelectorOperatorSymbol = "Eq"
	NotEq SelectorOperatorSymbol = "NotEq"
	In    SelectorOperatorSymbol = "In"
	NotIn SelectorOperatorSymbol = "NotIn"
)

type StringSelector

type StringSelector struct {
	// contains filtered or unexported fields
}

func NewStringSelector

func NewStringSelector(field string, matchMode SelectorOperatorSymbol) *StringSelector

TODO 增加operator操作符的入参

func (*StringSelector) Eq

func (s *StringSelector) Eq(value reflect.Value, matchValue string) (bool, error)

func (*StringSelector) GetField

func (s *StringSelector) GetField() string

func (*StringSelector) GetMatchFunc

func (s *StringSelector) GetMatchFunc(operatorSymbol string) (MatchFunc, error)

func (*StringSelector) In

func (s *StringSelector) In(value reflect.Value, matchValue string) (bool, error)

func (*StringSelector) NotEq

func (s *StringSelector) NotEq(value reflect.Value, matchValue string) (bool, error)

func (*StringSelector) NotIn

func (s *StringSelector) NotIn(value reflect.Value, matchValue string) (bool, error)

Jump to

Keyboard shortcuts

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