Documentation ¶
Overview ¶
Package channels contains various generic helpers for working with channels
Index ¶
- func Broadcast[T any](input <-chan T, outputs ...chan<- T)
- func Broadcaster[T any](input <-chan T, outputs ...chan<- T) errGroupFunc
- func Filter[T, U any](input <-chan T, filter func(T) (U, error), output chan<- U) error
- func FilterMany[T, U any](input <-chan T, filter func(T) ([]U, error), output chan<- U) error
- func Filterer[T, U any](input <-chan T, filter func(T) (U, error), output chan<- U) errGroupFunc
- func FiltererMany[T, U any](input <-chan T, filter func(T) ([]U, error), output chan<- U) errGroupFunc
- func Process[T any](input <-chan T, action func(T) error) error
- func Processor[T any](input <-chan T, action func(T) error) errGroupFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Broadcast ¶
func Broadcast[T any](input <-chan T, outputs ...chan<- T)
Broadcast relays all the messages received on input to outputs. It stops when input is closed, and closes outputs at that point. For efficient functionality, the outputs should be buffered.
func Broadcaster ¶
func Broadcaster[T any](input <-chan T, outputs ...chan<- T) errGroupFunc
Broadcaster wraps Broadcast to simplify errgroup setup
func Filter ¶
Filter reads each item from input and passes it to filter. If filter returns an error, it stops and returns that, otherwise it forwards filter's result to output. When input ends, output is closed and Filter returns nil.
func FilterMany ¶
FilterMany is like Filter, but allows the filter to return many output items for each input item.
func FiltererMany ¶
func FiltererMany[T, U any]( input <-chan T, filter func(T) ([]U, error), output chan<- U, ) errGroupFunc
FiltererMany wraps FilterMany for easy errgroup setup
Types ¶
This section is empty.