arrayfilter

package
v0.9.32 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package arrayfilter keeps the elements of an array that match a predicate.

Among a hundred-odd components there was no filter, no map and no count. array_get takes one element by index, array_split iterates, group_by buckets and collect fans in — every one of them sidesteps the question "which of these do I care about". So a flow that lists pods and wants the unhealthy ones writes JavaScript, and pod_list has exactly one setting, so every consumer writes it again.

The predicate is the same JSONPath dialect kv uses for its query port. One dialect across the palette is worth more than a cleverer second one.

Index

Constants

View Source
const (
	ComponentName = "array_filter"

	RequestPort = "request"
	ResultPort  = "result"
	ErrorPort   = "error"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component struct {
	module.Base
	// contains filtered or unexported fields
}

func (*Component) GetInfo

func (c *Component) GetInfo() module.ComponentInfo

func (*Component) Handle

func (c *Component) Handle(ctx context.Context, handler module.Handler, port string, msg interface{}) module.Result

func (*Component) Instance

func (c *Component) Instance() module.Component

func (*Component) OnSettings

func (c *Component) OnSettings(_ context.Context, msg any) error

func (*Component) Ports

func (c *Component) Ports() []module.Port

type Context

type Context any

type Error

type Error struct {
	Context Context `json:"context,omitempty" configurable:"true" title:"Context"`
	Error   string  `json:"error" title:"Error"`
}

type Request

type Request struct {
	Context Context `json:"context,omitempty" configurable:"true" title:"Context" description:"Passthrough, emitted with the result."`
	Array   []any   `json:"array" required:"true" title:"Array" description:"The items to filter. Map an upstream array straight in: {{$.pods}}."`
	Query   string  `` /* 190-byte string literal not displayed */
}

type Result

type Result struct {
	Context Context `json:"context,omitempty" configurable:"true" title:"Context"`
	Items   []any   `json:"items" title:"Items" description:"The items the predicate kept, in their original order."`
	Count   int     `json:"count" title:"Count" description:"How many matched — wire this to a router to branch on 'any' versus 'none'."`
	Total   int     `` /* 149-byte string literal not displayed */
}

type Settings

type Settings struct {
	// A predicate that cannot be evaluated against an item is ambiguous: it
	// may be a broken expression, or an item that simply lacks the field. The
	// two need different answers and only the flow's author knows which.
	SkipUnevaluable bool `` /* 273-byte string literal not displayed */
	EnableErrorPort bool `json:"enableErrorPort" title:"Enable Error Port" description:"Output errors to the error port instead of failing the run."`
}

Jump to

Keyboard shortcuts

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