match

package
v1.1.2 Latest Latest
Warning

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

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

Documentation

Overview

Install go-enum by `go get -u github.com/searKing/golang/tools/go-enum`

Install go-enum by `go get -u github.com/searKing/golang/tools/go-enum`

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	Mode:            ModeAllow,
	Matcher:         MatcherRegex,
	Pattern:         `^.*$`,
	ExactArrayMatch: pointer.Bool(true),
}

Functions

func MatcherTypeSliceContains

func MatcherTypeSliceContains(enums []MatcherType, sunEnums ...MatcherType) bool

MatcherTypeSliceContains reports whether sunEnums is within enums.

func MatcherTypeSliceContainsAny

func MatcherTypeSliceContainsAny(enums []MatcherType, sunEnums ...MatcherType) bool

MatcherTypeSliceContainsAny reports whether any sunEnum is within enums.

func ModeTypeSliceContains

func ModeTypeSliceContains(enums []ModeType, sunEnums ...ModeType) bool

ModeTypeSliceContains reports whether sunEnums is within enums.

func ModeTypeSliceContainsAny

func ModeTypeSliceContainsAny(enums []ModeType, sunEnums ...ModeType) bool

ModeTypeSliceContainsAny reports whether any sunEnum is within enums.

Types

type Config

type Config struct {
	Mode            ModeType                       `json:"mode,omitempty"`            // allow or deny
	Matcher         MatcherType                    `json:"matcher,omitempty"`         // regex, pattern, patternregex, comparison
	Pattern         interface{}                    `json:"pattern,omitempty"`         // single pattern
	Patterns        []interface{}                  `json:"patterns,omitempty"`        // list of patterns
	PatternsLogic   string                         `json:"patternsLogic,omitempty"`   // AND, OR only needed for pattern matches with multiple patterns
	Path            string                         `json:"path,omitempty"`            // path to match pattern against, if omitted uses payload as default
	ExactArrayMatch *bool                          `json:"exactArrayMatch,omitempty"` // if true pattern array must match payload array exactly, otherwise the pattern array can be a partial of the payload array
	Comparison      *comparison.Comparison         `json:"comparison,omitempty"`      // equal or notEqual comparison
	ComparisonTree  *comparison.ComparisonTreeNode `json:"comparisonTree,omitempty"`  // boolean tree of comparisons
}

Config can be passed into NewFilter() in order to configure the behavior of the sender.

func NewConfig

func NewConfig(config interface{}) (*Config, error)

func (*Config) FromJSON

func (c *Config) FromJSON(in string) error

func (*Config) FromYAML

func (c *Config) FromYAML(in string) error

func (*Config) JSON

func (c *Config) JSON() (string, error)

func (*Config) String

func (c *Config) String() string

func (*Config) Validate

func (c *Config) Validate() error

func (Config) WithDefaults

func (c Config) WithDefaults() *Config

func (*Config) YAML

func (c *Config) YAML() (string, error)

type Filter

type Filter struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewFilter

func NewFilter(tid tenant.Id, plugin string, name string, config interface{}, secrets secret.Vault, tableSyncer syncer.DeltaSyncer) (*Filter, error)

func (*Filter) Config

func (f *Filter) Config() interface{}

func (*Filter) EventErrorCount added in v1.1.2

func (f *Filter) EventErrorCount() int

func (*Filter) EventErrorVelocity added in v1.1.2

func (f *Filter) EventErrorVelocity() int

func (*Filter) EventFilterCount added in v1.1.2

func (f *Filter) EventFilterCount() int

func (*Filter) EventFilterVelocity added in v1.1.2

func (f *Filter) EventFilterVelocity() int

func (*Filter) EventSuccessCount added in v1.1.2

func (f *Filter) EventSuccessCount() int

func (*Filter) EventSuccessVelocity added in v1.1.2

func (f *Filter) EventSuccessVelocity() int

func (*Filter) EventTs added in v1.1.2

func (f *Filter) EventTs() int64

func (*Filter) Filter

func (f *Filter) Filter(evt event.Event) []event.Event

func (*Filter) Hash added in v1.1.2

func (f *Filter) Hash() string

func (*Filter) Name added in v0.2.1

func (f *Filter) Name() string

func (*Filter) Plugin added in v0.2.1

func (f *Filter) Plugin() string

func (*Filter) Tenant added in v0.3.0

func (f *Filter) Tenant() tenant.Id

type Matcher

type Matcher interface {
	Match(event event.Event) bool
}

type MatcherType

type MatcherType int
const (
	MatcherUnknown      MatcherType = iota // unknown
	MatcherRegex                           // regex
	MatcherPattern                         // pattern
	MatcherPatternRegex                    // patternregex
	MatcherComparison                      // comparison
)

func MatcherTypeValues

func MatcherTypeValues() []MatcherType

MatcherTypeValues returns all values of the enum

func ParseMatcherTypeString

func ParseMatcherTypeString(s string) (MatcherType, error)

ParseMatcherTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func (MatcherType) MarshalBinary

func (i MatcherType) MarshalBinary() (data []byte, err error)

MarshalBinary implements the encoding.BinaryMarshaler interface for MatcherType

func (MatcherType) MarshalJSON

func (i MatcherType) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for MatcherType

func (MatcherType) MarshalText

func (i MatcherType) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for MatcherType

func (MatcherType) MarshalYAML

func (i MatcherType) MarshalYAML() (interface{}, error)

MarshalYAML implements a YAML Marshaler for MatcherType

func (MatcherType) New

func (i MatcherType) New() *MatcherType

New returns a pointer to a new addr filled with the MatcherType value passed in.

func (MatcherType) Registered

func (i MatcherType) Registered() bool

IsAMatcherType returns "true" if the value is listed in the enum definition. "false" otherwise

func (MatcherType) String

func (i MatcherType) String() string

func (*MatcherType) UnmarshalBinary

func (i *MatcherType) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface for MatcherType

func (*MatcherType) UnmarshalJSON

func (i *MatcherType) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for MatcherType

func (*MatcherType) UnmarshalText

func (i *MatcherType) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for MatcherType

func (*MatcherType) UnmarshalYAML

func (i *MatcherType) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements a YAML Unmarshaler for MatcherType

type ModeType

type ModeType int
const (
	ModeUnknown ModeType = iota // unknown
	ModeAllow                   // allow
	ModeDeny                    // deny
)

func ModeTypeValues

func ModeTypeValues() []ModeType

ModeTypeValues returns all values of the enum

func ParseModeTypeString

func ParseModeTypeString(s string) (ModeType, error)

ParseModeTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func (ModeType) MarshalBinary

func (i ModeType) MarshalBinary() (data []byte, err error)

MarshalBinary implements the encoding.BinaryMarshaler interface for ModeType

func (ModeType) MarshalJSON

func (i ModeType) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for ModeType

func (ModeType) MarshalText

func (i ModeType) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for ModeType

func (ModeType) MarshalYAML

func (i ModeType) MarshalYAML() (interface{}, error)

MarshalYAML implements a YAML Marshaler for ModeType

func (ModeType) New

func (i ModeType) New() *ModeType

New returns a pointer to a new addr filled with the ModeType value passed in.

func (ModeType) Registered

func (i ModeType) Registered() bool

IsAModeType returns "true" if the value is listed in the enum definition. "false" otherwise

func (ModeType) String

func (i ModeType) String() string

func (*ModeType) UnmarshalBinary

func (i *ModeType) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface for ModeType

func (*ModeType) UnmarshalJSON

func (i *ModeType) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for ModeType

func (*ModeType) UnmarshalText

func (i *ModeType) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for ModeType

func (*ModeType) UnmarshalYAML

func (i *ModeType) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements a YAML Unmarshaler for ModeType

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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