{"modulePath":"github.com/InVisionApp/benthos","version":"v0.26.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package condition\n\nPackage condition contains logical operators that, based on their configuration, return boolean values from messages under certain circumstances.\n\n## Variables\n\n```go\nvar (\n\tTypeAnd      = \"and\"\n\tTypeCount    = \"count\"\n\tTypeJMESPath = \"jmespath\"\n\tTypeNot      = \"not\"\n\tTypeMetadata = \"metadata\"\n\tTypeOr       = \"or\"\n\tTypeResource = \"resource\"\n\tTypeStatic   = \"static\"\n\tTypeText     = \"text\"\n\tTypeXor      = \"xor\"\n)\n```\nString constants representing each condition type.\n\n```go\nvar Constructors = map[string]TypeSpec{}\n```\nConstructors is a map of all condition types with their specs.\n\n```go\nvar (\n\tErrInvalidMetadataOperator = errors.New(\"invalid metadata operator type\")\n)\n```\nErrors for the metadata condition.\n\n```go\nvar (\n\tErrInvalidTextOperator = errors.New(\"invalid text operator type\")\n)\n```\nErrors for the text condition.\n\n## Functions\n\n```go\nfunc Descriptions() string\n```\nDescriptions returns a formatted string of collated descriptions of each type.\n\n```go\nfunc SanitiseConfig(conf Config) (interface{}, error)\n```\nSanitiseConfig returns a sanitised version of the Config, meaning sections that aren't relevant to behaviour are removed.\n\n## Types\n\n```go\ntype And struct {\n\t// contains filtered or unexported fields\n}\n```\nAnd is a condition that returns the logical AND of all children.\n\n```go\nfunc (c *And) Check(msg types.Message) bool\n```\nCheck attempts to check a message part against a configured condition.\n\n```go\ntype AndConfig []Config\n```\nAndConfig is a configuration struct containing fields for the And condition.\n\n```go\nfunc NewAndConfig() AndConfig\n```\nNewAndConfig returns a AndConfig with default values.\n\n```go\ntype Config struct {\n\tType     string         `json:\"type\" yaml:\"type\"`\n\tAnd      AndConfig      `json:\"and\" yaml:\"and\"`\n\tCount    CountConfig    `json:\"count\" yaml:\"count\"`\n\tJMESPath JMESPathConfig `json:\"jmespath\" yaml:\"jmespath\"`\n\tNot      NotConfig      `json:\"not\" yaml:\"not\"`\n\tMetadata MetadataConfig `json:\"metadata\" yaml:\"metadata\"`\n\tOr       OrConfig       `json:\"or\" yaml:\"or\"`\n\tResource string         `json:\"resource\" yaml:\"resource\"`\n\tStatic   bool           `json:\"static\" yaml:\"static\"`\n\tText     TextConfig     `json:\"text\" yaml:\"text\"`\n\tXor      XorConfig      `json:\"xor\" yaml:\"xor\"`\n}\n```\nConfig is the all encompassing configuration struct for all condition types.\n\n```go\nfunc NewConfig() Config\n```\nNewConfig returns a configuration struct fully populated with default values.\n\n```go\nfunc (m *Config) UnmarshalJSON(bytes []byte) error\n```\nUnmarshalJSON ensures that when parsing configs that are in a slice the default values are still applied.\n\n```go\nfunc (m *Config) UnmarshalYAML(unmarshal func(interface{}) error) error\n```\nUnmarshalYAML ensures that when parsing configs that are in a slice the default values are still applied.\n\n```go\ntype Count struct {\n\t// contains filtered or unexported fields\n}\n```\nCount is a condition that counts each message and returns false once a target count has been reached, at which point it resets the counter and starts again.\n\n```go\nfunc (c *Count) Check(msg types.Message) bool\n```\nCheck attempts to check a message part against a configured condition.\n\n```go\ntype CountConfig struct {\n\tArg int `json:\"arg\" yaml:\"arg\"`\n}\n```\nCountConfig is a configuration struct containing fields for the Count condition.\n\n```go\nfunc NewCountConfig() CountConfig\n```\nNewCountConfig returns a CountConfig with default values.\n\n```go\ntype JMESPath struct {\n\t// contains filtered or unexported fields\n}\n```\nJMESPath is a condition that checks message against a jmespath query.\n\n```go\nfunc (c *JMESPath) Check(msg types.Message) bool\n```\nCheck attempts to check a message part against a configured condition.\n\n```go\ntype JMESPathConfig struct {\n\tPart  int    `json:\"part\" yaml:\"part\"`\n\tQuery string `json:\"query\" yaml:\"query\"`\n}\n```\nJMESPathConfig is a configuration struct containing fields for the jmespath condition.\n\n```go\nfunc NewJMESPathConfig() JMESPathConfig\n```\nNewJMESPathConfig returns a JMESPathConfig with default values.\n\n```go\ntype Metadata struct {\n\t// contains filtered or unexported fields\n}\n```\nMetadata is a condition that checks message text against logical operators.\n\n```go\nfunc (c *Metadata) Check(msg types.Message) bool\n```\nCheck attempts to check a message part against a configured condition.\n\n```go\ntype MetadataConfig struct {\n\tOperator string `json:\"operator\" yaml:\"operator\"`\n\tPart     int    `json:\"part\" yaml:\"part\"`\n\tKey      string `json:\"key\" yaml:\"key\"`\n\tArg      string `json:\"arg\" yaml:\"arg\"`\n}\n```\nMetadataConfig is a configuration struct containing fields for the metadata condition.\n\n```go\nfunc NewMetadataConfig() MetadataConfig\n```\nNewMetadataConfig returns a MetadataConfig with default values.\n\n```go\ntype Not struct {\n\t// contains filtered or unexported fields\n}\n```\nNot is a condition that returns the opposite of a child condition.\n\n```go\nfunc (c *Not) Check(msg types.Message) bool\n```\nCheck attempts to check a message part against a configured condition.\n\n```go\ntype NotConfig struct {\n\t*Config\n}\n```\nNotConfig is a configuration struct containing fields for the Not condition.\n\n```go\nfunc NewNotConfig() NotConfig\n```\nNewNotConfig returns a NotConfig with default values.\n\n```go\nfunc (m NotConfig) MarshalJSON() ([]byte, error)\n```\nMarshalJSON prints an empty object instead of nil.\n\n```go\nfunc (m NotConfig) MarshalYAML() (interface{}, error)\n```\nMarshalYAML prints an empty object instead of nil.\n\n```go\nfunc (m *NotConfig) UnmarshalJSON(bytes []byte) error\n```\nUnmarshalJSON ensures that when parsing child config it is initialised.\n\n```go\nfunc (m *NotConfig) UnmarshalYAML(unmarshal func(interface{}) error) error\n```\nUnmarshalYAML ensures that when parsing child config it is initialised.\n\n```go\ntype Or struct {\n\t// contains filtered or unexported fields\n}\n```\nOr is a condition that returns the logical or of all children.\n\n```go\nfunc (c *Or) Check(msg types.Message) bool\n```\nCheck attempts to check a message part against a configured condition.\n\n```go\ntype OrConfig []Config\n```\nOrConfig is a configuration struct containing fields for the Or condition.\n\n```go\nfunc NewOrConfig() OrConfig\n```\nNewOrConfig returns a OrConfig with default values.\n\n```go\ntype Resource struct {\n\t// contains filtered or unexported fields\n}\n```\nResource is a condition that returns the result of a condition resource.\n\n```go\nfunc (c *Resource) Check(msg types.Message) bool\n```\nCheck attempts to check a message part against a configured condition.\n\n```go\ntype Static struct {\n\t// contains filtered or unexported fields\n}\n```\nStatic is a condition that always returns a static boolean value.\n\n```go\nfunc (s *Static) Check(msg types.Message) bool\n```\nCheck attempts to check a message part against a configured condition.\n\n```go\ntype Text struct {\n\t// contains filtered or unexported fields\n}\n```\nText is a condition that checks message text against logical operators.\n\n```go\nfunc (c *Text) Check(msg types.Message) bool\n```\nCheck attempts to check a message part against a configured condition.\n\n```go\ntype TextConfig struct {\n\tOperator string `json:\"operator\" yaml:\"operator\"`\n\tPart     int    `json:\"part\" yaml:\"part\"`\n\tArg      string `json:\"arg\" yaml:\"arg\"`\n}\n```\nTextConfig is a configuration struct containing fields for the text condition.\n\n```go\nfunc NewTextConfig() TextConfig\n```\nNewTextConfig returns a TextConfig with default values.\n\n```go\ntype Type interface {\n\t// Check tests a message against a configured condition.\n\tCheck(msg types.Message) bool\n}\n```\nType reads a message, calculates a condition and returns a boolean.\n\n```go\nfunc New(conf Config, mgr types.Manager, log log.Modular, stats metrics.Type) (Type, error)\n```\nNew creates a condition type based on a condition configuration.\n\n```go\nfunc NewAnd(\n\tconf Config, mgr types.Manager, log log.Modular, stats metrics.Type,\n) (Type, error)\n```\nNewAnd returns an And condition.\n\n```go\nfunc NewCount(\n\tconf Config, mgr types.Manager, log log.Modular, stats metrics.Type,\n) (Type, error)\n```\nNewCount returns a Count processor.\n\n```go\nfunc NewJMESPath(\n\tconf Config, mgr types.Manager, log log.Modular, stats metrics.Type,\n) (Type, error)\n```\nNewJMESPath returns a JMESPath condition.\n\n```go\nfunc NewMetadata(\n\tconf Config, mgr types.Manager, log log.Modular, stats metrics.Type,\n) (Type, error)\n```\nNewMetadata returns a Metadata condition.\n\n```go\nfunc NewNot(\n\tconf Config, mgr types.Manager, log log.Modular, stats metrics.Type,\n) (Type, error)\n```\nNewNot returns a Not processor.\n\n```go\nfunc NewOr(\n\tconf Config, mgr types.Manager, log log.Modular, stats metrics.Type,\n) (Type, error)\n```\nNewOr returns an Or processor.\n\n```go\nfunc NewResource(\n\tconf Config, mgr types.Manager, log log.Modular, stats metrics.Type,\n) (Type, error)\n```\nNewResource returns a resource condition.\n\n```go\nfunc NewStatic(\n\tconf Config, mgr types.Manager, log log.Modular, stats metrics.Type,\n) (Type, error)\n```\nNewStatic returns a Static condition.\n\n```go\nfunc NewText(\n\tconf Config, mgr types.Manager, log log.Modular, stats metrics.Type,\n) (Type, error)\n```\nNewText returns a Text condition.\n\n```go\nfunc NewXor(\n\tconf Config, mgr types.Manager, log log.Modular, stats metrics.Type,\n) (Type, error)\n```\nNewXor returns an Xor processor.\n\n```go\ntype TypeSpec struct {\n\t// contains filtered or unexported fields\n}\n```\nTypeSpec Constructor and a usage description for each condition type.\n\n```go\ntype Xor struct {\n\t// contains filtered or unexported fields\n}\n```\nXor is a condition that returns the logical xor of all children.\n\n```go\nfunc (c *Xor) Check(msg types.Message) bool\n```\nCheck attempts to check a message part against a configured condition.\n\n```go\ntype XorConfig []Config\n```\nXorConfig is a configuration struct containing fields for the Xor condition.\n\n```go\nfunc NewXorConfig() XorConfig\n```\nNewXorConfig returns a XorConfig with default values.\n\n","path":"github.com/InVisionApp/benthos/lib/processor/condition","name":"condition","synopsis":"Package condition contains logical operators that, based on their configuration, return boolean values from messages under certain circumstances.","isRedistributable":true}
