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
- type Component
- func (c *Component) GetInfo() module.ComponentInfo
- func (c *Component) Handle(ctx context.Context, handler module.Handler, port string, msg interface{}) module.Result
- func (c *Component) Instance() module.Component
- func (c *Component) OnSettings(_ context.Context, msg any) error
- func (c *Component) Ports() []module.Port
- type Context
- type Error
- type Request
- type Result
- type Settings
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 ¶
func (*Component) GetInfo ¶
func (c *Component) GetInfo() module.ComponentInfo
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."`
}
Click to show internal directories.
Click to hide internal directories.