Documentation ¶
Overview ¶
Package condition contains logical operators that, based on their configuration, return boolean values from messages under certain circumstances.
Index ¶
- Variables
- func Descriptions() string
- func SanitiseConfig(conf Config) (interface{}, error)
- type And
- type AndConfig
- type Config
- type Content
- type ContentConfig
- type Not
- type NotConfig
- type Or
- type OrConfig
- type Resource
- type Type
- func New(conf Config, mgr types.Manager, log log.Modular, stats metrics.Type) (Type, error)
- func NewAnd(conf Config, mgr types.Manager, log log.Modular, stats metrics.Type) (Type, error)
- func NewContent(conf Config, mgr types.Manager, log log.Modular, stats metrics.Type) (Type, error)
- func NewNot(conf Config, mgr types.Manager, log log.Modular, stats metrics.Type) (Type, error)
- func NewOr(conf Config, mgr types.Manager, log log.Modular, stats metrics.Type) (Type, error)
- func NewResource(conf Config, mgr types.Manager, log log.Modular, stats metrics.Type) (Type, error)
- type TypeSpec
Constants ¶
This section is empty.
Variables ¶
var Constructors = map[string]TypeSpec{}
Constructors is a map of all condition types with their specs.
var (
ErrInvalidContentOperator = errors.New("invalid content operator type")
)
Errors for the content condition.
Functions ¶
func Descriptions ¶
func Descriptions() string
Descriptions returns a formatted string of collated descriptions of each type.
func SanitiseConfig ¶
SanitiseConfig returns a sanitised version of the Config, meaning sections that aren't relevant to behaviour are removed.
Types ¶
type And ¶ added in v0.9.4
type And struct {
// contains filtered or unexported fields
}
And is a condition that returns the logical AND of all children.
type AndConfig ¶ added in v0.9.4
type AndConfig []Config
AndConfig is a configuration struct containing fields for the And condition.
func NewAndConfig ¶ added in v0.9.4
func NewAndConfig() AndConfig
NewAndConfig returns a AndConfig with default values.
type Config ¶
type Config struct { Type string `json:"type" yaml:"type"` And AndConfig `json:"and" yaml:"and"` Content ContentConfig `json:"content" yaml:"content"` Not NotConfig `json:"not" yaml:"not"` Or OrConfig `json:"or" yaml:"or"` Resource string `json:"resource" yaml:"resource"` }
Config is the all encompassing configuration struct for all condition types.
func NewConfig ¶
func NewConfig() Config
NewConfig returns a configuration struct fully populated with default values.
func (*Config) UnmarshalJSON ¶
UnmarshalJSON ensures that when parsing configs that are in a slice the default values are still applied.
func (*Config) UnmarshalYAML ¶
UnmarshalYAML ensures that when parsing configs that are in a slice the default values are still applied.
type Content ¶ added in v0.9.4
type Content struct {
// contains filtered or unexported fields
}
Content is a condition that checks message content against logical operators.
type ContentConfig ¶ added in v0.9.4
type ContentConfig struct { Operator string `json:"operator" yaml:"operator"` Part int `json:"part" yaml:"part"` Arg string `json:"arg" yaml:"arg"` }
ContentConfig is a configuration struct containing fields for the content condition.
func NewContentConfig ¶ added in v0.9.4
func NewContentConfig() ContentConfig
NewContentConfig returns a ContentConfig with default values.
type Not ¶ added in v0.9.4
type Not struct {
// contains filtered or unexported fields
}
Not is a condition that returns the opposite of another condition.
type NotConfig ¶ added in v0.9.4
type NotConfig struct {
*Config
}
NotConfig is a configuration struct containing fields for the Not condition.
func NewNotConfig ¶ added in v0.9.4
func NewNotConfig() NotConfig
NewNotConfig returns a NotConfig with default values.
func (NotConfig) MarshalJSON ¶ added in v0.9.4
MarshalJSON prints an empty object instead of nil.
func (NotConfig) MarshalYAML ¶ added in v0.9.4
MarshalYAML prints an empty object instead of nil.
func (*NotConfig) UnmarshalJSON ¶ added in v0.9.4
UnmarshalJSON ensures that when parsing child config it is initialised.
func (*NotConfig) UnmarshalYAML ¶ added in v0.9.4
UnmarshalYAML ensures that when parsing child config it is initialised.
type Or ¶ added in v0.9.4
type Or struct {
// contains filtered or unexported fields
}
Or is a condition that returns the logical or of all children.
type OrConfig ¶ added in v0.9.4
type OrConfig []Config
OrConfig is a configuration struct containing fields for the Or condition.
func NewOrConfig ¶ added in v0.9.4
func NewOrConfig() OrConfig
NewOrConfig returns a OrConfig with default values.
type Resource ¶ added in v0.9.7
type Resource struct {
// contains filtered or unexported fields
}
Resource is a condition that returns the result of a condition resource.
type Type ¶
type Type interface { // Check tests a message against a configured condition. Check(msg types.Message) bool }
Type reads a message, calculates a condition and returns a boolean.
func NewContent ¶ added in v0.9.4
func NewContent( conf Config, mgr types.Manager, log log.Modular, stats metrics.Type, ) (Type, error)
NewContent returns a Content processor.