Skip to content

TeeN and CombineN #31

Description

@kalexmills-splunk

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions