splunk / pipelines

Concurrent processing pipelines in Go.
MIT License
21 stars 8 forks source link

Consider Filter stage #15

Open kalexmills-splunk opened 2 years ago

kalexmills-splunk commented 2 years ago

A Filter stage could be useful.

// Filter receives all values from the provided channel and sends only values for which filter(t) is true.
Filter[T any](ctx context.Context, in <-chan T, filter func(T) bool) <-chan T
kalexmills-splunk commented 2 years ago

FYI: This is just syntactic sugar over OptionMap, which itself is syntactic sugar over FlatMap.

i.e. both OptionMap and Filter can be implemented using FlatMap. This only achieves a duplication in code, nothing more.