splunk / pipelines

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

TeeN and CombineN #31

Open kalexmills-splunk opened 2 years ago

kalexmills-splunk commented 2 years ago

At the moment; Tee and Combine only work in pairs. It is, of course, possible to write TeeN and CombineN, which work on arbitrary slices of channels, using the following signatures.

// TeeN converts a "chan T" into n "chan T", each of which receive exactly the same values,
// possibly in different orders.
func TeeN[T any](ctx context.Context, in <-chan T, n int, opts ...Option) ([]<-chan T)
// CombineN converts a "[]chan T" into a "chan T".
func CombineN[T any](ctx context.Context, ins []<-chan T, opts ...Option) <-chan T

This would be a backwards compatible change which some users may want. Until it has been completed, combining Tee and Combine in pairs is possible as a workaround.