conditions

package
v0.0.0-...-38575d5 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: AGPL-3.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NetworkContains

func NetworkContains(ip net.IP, networks ...string) (bool, error)

NetworkContains returns true if the given IP is contained by any of the networks. networks can be a CIDR or any of these named networks:

  • loopback
  • global_unicast
  • unicast
  • link_local_unicast
  • interface_local_multicast
  • link_local_multicast
  • multicast
  • unspecified
  • private
  • public

Types

type And

type And []Condition

And is a compound condition that combines multiple conditions with logical AND.

func NewAndCondition

func NewAndCondition(conditions []Condition) And

NewAndCondition builds this condition from a slice of Condition objects.

func (And) Check

func (c And) Check(event ValuesMap) bool

Check determines whether the given event matches this condition

func (And) String

func (c And) String() (s string)

type ClusterAvailable

type ClusterAvailable []string

func NewClusterAvailableCondition

func NewClusterAvailableCondition(names []string) ClusterAvailable

func (ClusterAvailable) Check

func (c ClusterAvailable) Check(event ValuesMap) bool

func (ClusterAvailable) String

func (c ClusterAvailable) String() string

type Condition

type Condition interface {
	Check(event ValuesMap) bool
	String() string
}

Condition is the interface for all defined conditions

func NewCondition

func NewCondition(config *Config) (Condition, error)

NewCondition takes a Config and turns it into a real Condition

func NewConditionList

func NewConditionList(config []Config) ([]Condition, error)

NewConditionList takes a slice of Config objects and turns them into real Condition objects.

type Config

type Config struct {
	Equals           *Fields                `config:"equals"`
	Contains         *Fields                `config:"contains"`
	Prefix           map[string]interface{} `config:"prefix"`
	Suffix           map[string]interface{} `config:"suffix"`
	Regexp           *Fields                `config:"regexp"`
	Range            *Fields                `config:"range"`
	QueueHasLag      []string               `config:"queue_has_lag"`
	ConsumerHasLag   *Fields                `config:"consumer_has_lag"`
	ClusterAvailable []string               `config:"cluster_available"`
	Exists           []string               `config:"exists"`
	Network          map[string]interface{} `config:"network"`
	OR               []Config               `config:"or"`
	AND              []Config               `config:"and"`
	NOT              *Config                `config:"not"`
	IN               map[string]interface{} `config:"in"`
}

Config represents a configuration for a condition, as you would find it in the config files.

type ConsumerHasLag

type ConsumerHasLag struct {
	Queue    string
	Group    string
	Consumer string
}

func NewConsumerHasLagCondition

func NewConsumerHasLagCondition(fields map[string]interface{}) (c ConsumerHasLag)

func (ConsumerHasLag) Check

func (c ConsumerHasLag) Check(event ValuesMap) bool

func (ConsumerHasLag) Name

func (c ConsumerHasLag) Name() string

func (ConsumerHasLag) String

func (c ConsumerHasLag) String() string

type Context

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

func (*Context) AddContext

func (this *Context) AddContext(ctx ValuesMap) *Context

func (*Context) GetValue

func (this *Context) GetValue(k string) (interface{}, error)

type Equals

type Equals map[string]equalsValue

Equals is a Condition for testing string equality.

func NewEqualsCondition

func NewEqualsCondition(fields map[string]interface{}) (c Equals, err error)

NewEqualsCondition builds a new Equals using the given configuration of string equality checks.

func (Equals) Check

func (c Equals) Check(event ValuesMap) bool

Check determines whether the given event matches this condition.

func (Equals) String

func (c Equals) String() string

type Exists

type Exists []string

Exists is a Condition for checking field existence.

func NewExistsCondition

func NewExistsCondition(fields []string) (hasFieldsCondition Exists)

NewExistsCondition builds a new Exists checking the given list of fields.

func (Exists) Check

func (c Exists) Check(event ValuesMap) bool

Check determines whether the given event matches this condition

func (Exists) String

func (c Exists) String() string

type Fields

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

Fields represents an arbitrary map in a config file.

func (*Fields) Unpack

func (f *Fields) Unpack(to interface{}) error

Unpack unpacks nested fields set with dot notation like foo.bar into the proper nesting in a nested map/slice structure.

type InArray

type InArray struct {
	Field string
	Data  []interface{}
}

func NewInArrayCondition

func NewInArrayCondition(fields map[string]interface{}) (c InArray, err error)

func (InArray) Check

func (c InArray) Check(event ValuesMap) bool

func (InArray) Name

func (c InArray) Name() string

func (InArray) String

func (c InArray) String() string

type Matcher

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

Matcher is a Condition that works with beat's internal notion of a string matcher.

func NewMatcherCondition

func NewMatcherCondition(
	name string,
	fields map[string]interface{},
	compile func(string) (match.Matcher, error),
) (condition Matcher, err error)

NewMatcherCondition builds a new Matcher with the given human name using the provided config fields. The compiler function will take those fields and compile them.

func (Matcher) Check

func (c Matcher) Check(event ValuesMap) bool

Check determines whether the given event matches this condition.

func (Matcher) String

func (c Matcher) String() string

type MutableValueMap

type MutableValueMap interface {
	PutValue(s string, value interface{}) (interface{}, error)
}

type Network

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

Network is a condition that tests if an IP address is in a network range.

func NewNetworkCondition

func NewNetworkCondition(fields map[string]interface{}) (*Network, error)

NewNetworkCondition builds a new Network using the given configuration.

func (*Network) Check

func (c *Network) Check(event ValuesMap) bool

Check determines whether the given event matches this condition.

func (*Network) String

func (c *Network) String() string

String returns a string representation of the Network condition.

type Not

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

Not is a condition that negates its inner condition.

func NewNotCondition

func NewNotCondition(c Condition) (Not, error)

NewNotCondition builds a new Not condition that negates the provided Condition.

func (Not) Check

func (c Not) Check(event ValuesMap) bool

Check determines whether the given event matches this condition.

func (Not) String

func (c Not) String() string

type Or

type Or []Condition

Or is a compound condition that combines multiple conditions with logical OR.

func NewOrCondition

func NewOrCondition(conditions []Condition) Or

NewOrCondition builds this condition from a slice of Condition objects.

func (Or) Check

func (c Or) Check(event ValuesMap) bool

Check determines whether the given event matches this condition.

func (Or) String

func (c Or) String() (s string)

type Prefix

type Prefix struct {
	Field string
	Data  string
}

Prefix is a Condition for checking field is prefix with some specify string.

func NewPrefixCondition

func NewPrefixCondition(fields map[string]interface{}) (hasFieldsCondition Prefix, err error)

func (Prefix) Check

func (c Prefix) Check(event ValuesMap) bool

Check determines whether the given event matches this condition

func (Prefix) String

func (c Prefix) String() string

type QueueHasLag

type QueueHasLag []string

func NewQueueHasLagCondition

func NewQueueHasLagCondition(queueName []string) QueueHasLag

func (QueueHasLag) Check

func (c QueueHasLag) Check(event ValuesMap) bool

func (QueueHasLag) String

func (c QueueHasLag) String() string

type Range

type Range map[string]rangeValue

Range is a Condition type for checking against ranges.

func NewRangeCondition

func NewRangeCondition(config map[string]interface{}) (c Range, err error)

NewRangeCondition builds a new Range from a map of ranges.

func (Range) Check

func (c Range) Check(event ValuesMap) bool

Check determines whether the given event matches this condition.

func (Range) String

func (c Range) String() string

type RemovableValueMap

type RemovableValueMap interface {
	RemoveValue(s string) (bool, error)
}

type Suffix

type Suffix struct {
	Field string
	Data  string
}

Suffix is a Condition for checking field if the field whether end with specify string or not.

func NewSuffixCondition

func NewSuffixCondition(fields map[string]interface{}) (hasFieldsCondition Suffix, err error)

func (Suffix) Check

func (c Suffix) Check(event ValuesMap) bool

Check determines whether the given event matches this condition

func (Suffix) String

func (c Suffix) String() string

type ValuesMap

type ValuesMap interface {
	// GetValue returns the given field from the map
	GetValue(string) (interface{}, error)
}

ValuesMap provides a common interface to read matchers for condition checking

Jump to

Keyboard shortcuts

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