Documentation
¶
Index ¶
- func BrokenSinkError() error
- type ChanElem
- type StreamingChan
- func CreateChannel[T any](generator func(sink func(data T, context context.Context) bool) error) StreamingChan[T]
- func CreateChannelBuffered[T any](bufSize int, ...) StreamingChan[T]
- func CreateChannelBufferedContext[T any](ctx context.Context, bufSize int, ...) StreamingChan[T]
- func CreateChannelContext[T any](ctx context.Context, ...) StreamingChan[T]
- func FlapMap[P any, Q any](ch StreamingChan[P], mapper func(data P) StreamingChan[Q]) StreamingChan[Q]
- func FlatMapContext[P any, Q any](ctx context.Context, ch StreamingChan[P], mapper func(data P) StreamingChan[Q]) StreamingChan[Q]
- func Map[P any, Q any](ch StreamingChan[P], mapper func(data P) Q) StreamingChan[Q]
- func MapContext[P any, Q any](ctx context.Context, ch StreamingChan[P], mapper func(data P) Q) StreamingChan[Q]
- func SingleElemChannel[T any](data T) StreamingChan[T]
- func SingleElemChannelContext[T any](ctx context.Context, data T) StreamingChan[T]
- func SingleElemChannelErr[T any](data T, err error) StreamingChan[T]
- func SingleElemChannelErrContext[T any](ctx context.Context, data T, err error) StreamingChan[T]
- func SliceToChannel[T any](data []T) StreamingChan[T]
- func SliceToChannelContext[T any](ctx context.Context, data []T) StreamingChan[T]
- func (ch StreamingChan[T]) CollectToSlice() ([]T, error)
- func (ch StreamingChan[T]) CollectToSliceContext(ctx context.Context) ([]T, error)
- func (ch StreamingChan[T]) FlatMap(mapper func(data T) StreamingChan[any]) StreamingChan[any]
- func (ch StreamingChan[T]) ForEachChanElem(onEach func(data T) error) error
- func (ch StreamingChan[T]) ForEachChanElemContext(ctx context.Context, onEach func(data T) error) error
- func (ch StreamingChan[T]) Map(mapper func(data T) any) StreamingChan[any]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BrokenSinkError ¶
func BrokenSinkError() error
Types ¶
type ChanElem ¶
type ChanElem[T any] struct { // contains filtered or unexported fields }
func WrapChanData ¶
func WrapChanErr ¶
type StreamingChan ¶
func CreateChannel ¶
func CreateChannelBuffered ¶
func CreateChannelBufferedContext ¶ added in v0.6.0
func CreateChannelBufferedContext[T any](ctx context.Context, bufSize int, generator func(sink func(data []T, sendContext context.Context) bool) error) StreamingChan[T]
CreateChannelBufferedContext creates a context-owned stream with the exact requested finite capacity. Each page is delivered in order, one element at a time, and cancellation interrupts blocked value and terminal-error sends.
func CreateChannelContext ¶ added in v0.6.0
func CreateChannelContext[T any](ctx context.Context, generator func(sink func(data T, sendContext context.Context) bool) error) StreamingChan[T]
CreateChannelContext creates an unbuffered context-owned stream. The generator must return after sink reports false. A non-nil generator error is sent at most once while the operation context remains active.
func FlapMap ¶
func FlapMap[P any, Q any](ch StreamingChan[P], mapper func(data P) StreamingChan[Q]) StreamingChan[Q]
func FlatMapContext ¶ added in v0.6.0
func FlatMapContext[P any, Q any](ctx context.Context, ch StreamingChan[P], mapper func(data P) StreamingChan[Q]) StreamingChan[Q]
FlatMapContext expands source values in order while all owned receives and sends observe the same operation context. FlapMap remains available for compatibility with its historical spelling.
func Map ¶
func Map[P any, Q any](ch StreamingChan[P], mapper func(data P) Q) StreamingChan[Q]
func MapContext ¶ added in v0.6.0
func MapContext[P any, Q any](ctx context.Context, ch StreamingChan[P], mapper func(data P) Q) StreamingChan[Q]
MapContext maps source values in order and shares ctx across receiving and sending so an abandoned chain can be canceled as one operation.
func SingleElemChannel ¶
func SingleElemChannel[T any](data T) StreamingChan[T]
func SingleElemChannelContext ¶ added in v0.6.0
func SingleElemChannelContext[T any](ctx context.Context, data T) StreamingChan[T]
SingleElemChannelContext returns an unbuffered, producer-owned stream whose only send is abandoned when the operation context is canceled.
func SingleElemChannelErr ¶
func SingleElemChannelErr[T any](data T, err error) StreamingChan[T]
func SingleElemChannelErrContext ¶ added in v0.6.0
func SingleElemChannelErrContext[T any](ctx context.Context, data T, err error) StreamingChan[T]
SingleElemChannelErrContext returns either one value or one terminal error. Cancellation suppresses a send that has not completed yet.
func SliceToChannel ¶
func SliceToChannel[T any](data []T) StreamingChan[T]
func SliceToChannelContext ¶ added in v0.6.0
func SliceToChannelContext[T any](ctx context.Context, data []T) StreamingChan[T]
SliceToChannelContext streams data in source order until completion or cancellation. The returned unbuffered channel is always closed by its producer.
func (StreamingChan[T]) CollectToSlice ¶
func (ch StreamingChan[T]) CollectToSlice() ([]T, error)
func (StreamingChan[T]) CollectToSliceContext ¶ added in v0.6.0
func (ch StreamingChan[T]) CollectToSliceContext(ctx context.Context) ([]T, error)
CollectToSliceContext collects values received before completion or cancellation. Partial values are returned together with the terminal error.
func (StreamingChan[T]) FlatMap ¶
func (ch StreamingChan[T]) FlatMap(mapper func(data T) StreamingChan[any]) StreamingChan[any]
func (StreamingChan[T]) ForEachChanElem ¶
func (ch StreamingChan[T]) ForEachChanElem(onEach func(data T) error) error
func (StreamingChan[T]) ForEachChanElemContext ¶ added in v0.6.0
func (ch StreamingChan[T]) ForEachChanElemContext(ctx context.Context, onEach func(data T) error) error
ForEachChanElemContext consumes values until closure, a terminal stream error, callback failure, or operation cancellation.
func (StreamingChan[T]) Map ¶
func (ch StreamingChan[T]) Map(mapper func(data T) any) StreamingChan[any]