package
1.0.9
Repository: https://github.com/pipelane/pipelaner.git
Documentation: pkg.go.dev

# README

Filter

The Filter transform component evaluates incoming messages against a custom rule (written in an expr rule-based engine) and processes only those that match the rule.


Class Definition

class Filter extends Transform {
  fixed sourceName = "filter"
  code: String
}

Attributes

AttributeTypeDescriptionDefault Value
codeStringThe filtering rule written in the expr engine syntax.Required

I/O Types

  • Input Type: map[string]any, string, []byte
  • Output Type: map[string]any, string, []byte

Pkl Configuration Example

Basic Filter Transform

new Transforms.Filter {
  name = "example-filter"
  code = "Data.count > 5"
}

Description

The Filter transform component uses a custom rule defined in the expr engine to evaluate each incoming message. Only messages that satisfy the rule are passed to the next component.


Example from Unit Test

The following test demonstrates filtering messages where the count field in a JSON object is greater than 5:

{
	name: "test filtering string return 10",
	args: args{
		code: "Data.count > 5",
		val:  []byte("{"count":10}"),
	},
	want: []byte("{"count":10}"),
},

Pkl Configuration Matching with Unit Test

The equivalent Pkl configuration for the test case above:

new Transforms.Filter {
  name = "filter-count-test"
  code = "Data.count > 5"
}

Use Cases

  1. Message Filtering
    • Filter out messages that do not meet specific criteria.
  2. Data Validation
    • Process only messages with valid or desired data.

Notes


# Variables

No description provided by the author

# Structs

No description provided by the author
No description provided by the author