Documentation
¶
Overview ¶
Package flx provides generic stream processing with dynamic concurrency control, explicit context-aware transforms, and reusable retry, timeout, and parallel execution helpers.
Module path: github.com/ezra-sullivan/flx
Index ¶
- Variables
- func DoWithRetry(fn func() error, opts ...RetryOption) error
- func DoWithRetryCtx(ctx context.Context, fn func(context.Context, int) error, opts ...RetryOption) error
- func DoWithTimeout(fn func() error, timeout time.Duration, opts ...TimeoutOption) error
- func DoWithTimeoutCtx(fn func(context.Context) error, timeout time.Duration, opts ...TimeoutOption) error
- func Parallel(fns ...func())
- func ParallelErr(fns ...func() error) error
- func ParallelWithErrorStrategy(strategy ErrorStrategy, fns ...func()) error
- func Reduce[T, R any](s Stream[T], fn func(<-chan T) (R, error)) (R, error)
- func SendContext[T any](ctx context.Context, pipe chan<- T, item T) bool
- type ConcurrencyController
- type DynamicSemaphore
- type ErrorStrategy
- type Group
- type Option
- func WithDynamicWorkers(controller *ConcurrencyController) Option
- func WithErrorStrategy(strategy ErrorStrategy) Option
- func WithForcedDynamicWorkers(controller *ConcurrencyController) Option
- func WithInterruptibleWorkers(controller *ConcurrencyController) Optiondeprecated
- func WithUnlimitedWorkers() Option
- func WithWorkers(workers int) Option
- type RetryOption
- type Stream
- func Chunk[T any](s Stream[T], n int) Stream[[]T]
- func Concat[T any](s Stream[T], others ...Stream[T]) Stream[T]
- func DistinctBy[T any, K comparable](s Stream[T], fn func(T) K) Stream[T]
- func DistinctByCount[T any, K comparable](s Stream[T], n int, fn func(T) K) Stream[T]
- func DistinctByWindow[T any, K comparable](ctx context.Context, s Stream[T], every time.Duration, fn func(T) K) Stream[T]
- func FlatMap[T, U any](s Stream[T], fn func(T, chan<- U), opts ...Option) Stream[U]
- func FlatMapContext[T, U any](ctx context.Context, s Stream[T], fn func(context.Context, T, chan<- U), ...) Stream[U]
- func FlatMapContextErr[T, U any](ctx context.Context, s Stream[T], fn func(context.Context, T, chan<- U) error, ...) Stream[U]
- func FlatMapErr[T, U any](s Stream[T], fn func(T, chan<- U) error, opts ...Option) Stream[U]
- func FlatStage[I, O any](ctx context.Context, in Stream[I], fn func(context.Context, I, chan<- O), ...) Stream[O]
- func FlatStageErr[I, O any](ctx context.Context, in Stream[I], fn func(context.Context, I, chan<- O) error, ...) Stream[O]
- func From[T any](generate func(chan<- T)) Stream[T]
- func FromChan[T any](source <-chan T) Stream[T]
- func GroupBy[T any, K comparable](s Stream[T], fn func(T) K) Stream[[]T]
- func GroupByCount[T any, K comparable](s Stream[T], n int, fn func(T) K) Stream[Group[K, T]]
- func GroupByWindow[T any, K comparable](ctx context.Context, s Stream[T], every time.Duration, fn func(T) K) Stream[Group[K, T]]
- func Map[T, U any](s Stream[T], fn func(T) U, opts ...Option) Stream[U]
- func MapContext[T, U any](ctx context.Context, s Stream[T], fn func(context.Context, T) U, ...) Stream[U]
- func MapContextErr[T, U any](ctx context.Context, s Stream[T], fn func(context.Context, T) (U, error), ...) Stream[U]
- func MapErr[T, U any](s Stream[T], fn func(T) (U, error), opts ...Option) Stream[U]
- func Stage[I, O any](ctx context.Context, in Stream[I], fn func(context.Context, I) O, ...) Stream[O]
- func StageErr[I, O any](ctx context.Context, in Stream[I], fn func(context.Context, I) (O, error), ...) Stream[O]
- func Tap[T any](ctx context.Context, in Stream[T], fn func(context.Context, T) error, ...) Stream[T]
- func Values[T any](items ...T) Stream[T]
- func (s Stream[T]) AllMatch(predicate func(T) bool) bool
- func (s Stream[T]) AllMatchErr(predicate func(T) bool) (bool, error)
- func (s Stream[T]) AnyMatch(predicate func(T) bool) bool
- func (s Stream[T]) AnyMatchErr(predicate func(T) bool) (bool, error)
- func (s Stream[T]) Buffer(n int) Stream[T]
- func (s Stream[T]) Collect() []T
- func (s Stream[T]) CollectErr() ([]T, error)
- func (s Stream[T]) Concat(others ...Stream[T]) Stream[T]
- func (s Stream[T]) Count() int
- func (s Stream[T]) CountErr() (int, error)
- func (s Stream[T]) Done()
- func (s Stream[T]) DoneErr() error
- func (s Stream[T]) Err() error
- func (s Stream[T]) Filter(fn func(T) bool, opts ...Option) Stream[T]
- func (s Stream[T]) First() (T, bool)
- func (s Stream[T]) FirstErr() (T, bool, error)
- func (s Stream[T]) ForAll(fn func(<-chan T))
- func (s Stream[T]) ForAllErr(fn func(<-chan T)) error
- func (s Stream[T]) ForEach(fn func(T))
- func (s Stream[T]) ForEachErr(fn func(T)) error
- func (s Stream[T]) Head(n int64) Stream[T]
- func (s Stream[T]) Last() (T, bool)
- func (s Stream[T]) LastErr() (T, bool, error)
- func (s Stream[T]) Max(less func(T, T) bool) (T, bool)
- func (s Stream[T]) MaxErr(less func(T, T) bool) (T, bool, error)
- func (s Stream[T]) Min(less func(T, T) bool) (T, bool)
- func (s Stream[T]) MinErr(less func(T, T) bool) (T, bool, error)
- func (s Stream[T]) NoneMatch(predicate func(T) bool) bool
- func (s Stream[T]) NoneMatchErr(predicate func(T) bool) (bool, error)
- func (s Stream[T]) Parallel(fn func(T), opts ...Option)
- func (s Stream[T]) ParallelErr(fn func(T) error, opts ...Option) error
- func (s Stream[T]) Reverse() Stream[T]
- func (s Stream[T]) Skip(n int64) Stream[T]
- func (s Stream[T]) Sort(less func(T, T) bool) Stream[T]
- func (s Stream[T]) Tail(n int64) Stream[T]
- func (s Stream[T]) Tap(ctx context.Context, fn func(context.Context, T) error, opts ...Option) Stream[T]
- func (s Stream[T]) Through(ctx context.Context, fn func(context.Context, T) T, opts ...Option) Stream[T]
- func (s Stream[T]) ThroughErr(ctx context.Context, fn func(context.Context, T) (T, error), opts ...Option) Stream[T]
- type TimeoutOption
- type WorkerError
Constants ¶
This section is empty.
Variables ¶
var ( // ErrWorkerLimitReduced reports that a worker was canceled because a forced // dynamic controller shrank below the number of active workers. ErrWorkerLimitReduced = control.ErrWorkerLimitReduced // ErrInvalidErrorStrategy reports that an operation received an unsupported // worker error handling mode. ErrInvalidErrorStrategy = config.ErrInvalidErrorStrategy // ErrNilController reports that a dynamic-worker option received a nil // concurrency controller. ErrNilController = config.ErrNilController // ErrInterruptibleWorkersRequireContextTransform reports that forced dynamic // workers were requested for a transform that does not accept a context. ErrInterruptibleWorkersRequireContextTransform = config.ErrInterruptibleWorkersRequireContextTransform )
var ( // ErrCanceled is an alias for context.Canceled. ErrCanceled = context.Canceled // ErrTimeout is an alias for context.DeadlineExceeded. ErrTimeout = context.DeadlineExceeded // ErrNilContext reports that a required parent context was nil. ErrNilContext = errors.New("flx: nil context") // ErrNegativeTimeout reports that a timeout duration was negative. ErrNegativeTimeout = errors.New("flx: timeout must not be negative") // ErrInvalidRetryTimes reports that a retry count was zero or negative. ErrInvalidRetryTimes = errors.New("flx: retry times must be greater than 0") // ErrNegativeRetryInterval reports that a retry interval was negative. ErrNegativeRetryInterval = errors.New("flx: retry interval must not be negative") // ErrNegativeRetryTimeout reports that a total retry timeout was negative. ErrNegativeRetryTimeout = errors.New("flx: retry timeout must not be negative") // ErrNegativeAttemptTimeout reports that a per-attempt timeout was negative. ErrNegativeAttemptTimeout = errors.New("flx: attempt timeout must not be negative") // ErrAttemptTimeoutRequiresRetryCtx reports that attempt timeouts only work // with the context-aware retry API. ErrAttemptTimeoutRequiresRetryCtx = errors.New("flx: WithAttemptTimeout requires DoWithRetryCtx") // ErrRetryAttemptTimeout reports that one retry attempt exceeded its own // attempt timeout. ErrRetryAttemptTimeout = errors.New("flx: retry attempt timeout") )
var ( // ErrInvalidWindowCount reports that a count-based window size was less than // one. ErrInvalidWindowCount = errors.New("flx: window count must be greater than 0") // ErrInvalidWindowDuration reports that a time-based window duration was not // positive. ErrInvalidWindowDuration = errors.New("flx: window duration must be positive") )
Functions ¶
func DoWithRetry ¶
func DoWithRetry(fn func() error, opts ...RetryOption) error
DoWithRetry executes fn until it succeeds or the retry budget is exhausted.
func DoWithRetryCtx ¶
func DoWithRetryCtx(ctx context.Context, fn func(context.Context, int) error, opts ...RetryOption) error
DoWithRetryCtx executes fn until it succeeds or the retry budget is exhausted, passing the current attempt context and zero-based attempt index.
func DoWithTimeout ¶
func DoWithTimeout(fn func() error, timeout time.Duration, opts ...TimeoutOption) error
DoWithTimeout runs fn with a derived timeout context and returns its result.
func DoWithTimeoutCtx ¶
func DoWithTimeoutCtx(fn func(context.Context) error, timeout time.Duration, opts ...TimeoutOption) error
DoWithTimeoutCtx runs fn with a derived timeout context and passes that context into the callback.
func Parallel ¶
func Parallel(fns ...func())
Parallel runs each function in its own goroutine and panics if the chosen fail-fast strategy records an error.
func ParallelErr ¶
ParallelErr runs each function in its own goroutine and returns the joined worker errors without applying stream fail-fast semantics.
func ParallelWithErrorStrategy ¶
func ParallelWithErrorStrategy(strategy ErrorStrategy, fns ...func()) error
ParallelWithErrorStrategy runs each function in its own goroutine and applies strategy to worker panics and returned errors.
Types ¶
type ConcurrencyController ¶
type ConcurrencyController struct {
// contains filtered or unexported fields
}
ConcurrencyController coordinates resizable worker limits for dynamic stream operations. It is safe for concurrent use.
func NewConcurrencyController ¶
func NewConcurrencyController(workers int) *ConcurrencyController
NewConcurrencyController returns a controller whose worker limit starts at workers, clamped to at least one slot.
func (*ConcurrencyController) ActiveWorkers ¶
func (c *ConcurrencyController) ActiveWorkers() int
ActiveWorkers returns the number of workers currently holding semaphore slots.
func (*ConcurrencyController) SetWorkers ¶
func (c *ConcurrencyController) SetWorkers(n int)
SetWorkers updates the target worker count. When the limit shrinks, the newest registered interruptible workers are canceled until the active count fits within the new limit.
func (*ConcurrencyController) Workers ¶
func (c *ConcurrencyController) Workers() int
Workers returns the configured worker limit.
type DynamicSemaphore ¶
type DynamicSemaphore struct {
// contains filtered or unexported fields
}
DynamicSemaphore is a resizable semaphore used by dynamic worker pipelines. It is safe for concurrent use.
func NewDynamicSemaphore ¶
func NewDynamicSemaphore(n int) *DynamicSemaphore
NewDynamicSemaphore returns a semaphore with capacity n, clamped to at least one slot.
func (*DynamicSemaphore) Acquire ¶
func (s *DynamicSemaphore) Acquire()
Acquire blocks until a slot is available.
func (*DynamicSemaphore) AcquireCtx ¶
func (s *DynamicSemaphore) AcquireCtx(ctx context.Context) error
AcquireCtx blocks until a slot is available or ctx is canceled.
func (*DynamicSemaphore) Cap ¶
func (s *DynamicSemaphore) Cap() int
Cap returns the configured semaphore capacity.
func (*DynamicSemaphore) Current ¶
func (s *DynamicSemaphore) Current() int
Current returns the number of slots currently held.
func (*DynamicSemaphore) Release ¶
func (s *DynamicSemaphore) Release()
Release frees one acquired slot and wakes the next waiter if capacity is available.
func (*DynamicSemaphore) Resize ¶
func (s *DynamicSemaphore) Resize(n int)
Resize updates the semaphore capacity and wakes queued waiters when the new capacity allows additional work to start.
type ErrorStrategy ¶
type ErrorStrategy uint8
ErrorStrategy controls how concurrent operations react to worker failures.
const ( // ErrorStrategyFailFast cancels the operation and makes non-Err terminals // panic once the failure is observed. ErrorStrategyFailFast ErrorStrategy = iota // ErrorStrategyCollect records worker errors and returns them from Err // terminals without canceling sibling workers. ErrorStrategyCollect // ErrorStrategyLogAndContinue logs worker errors and allows the operation to // continue without recording them in stream state. ErrorStrategyLogAndContinue )
func (ErrorStrategy) String ¶
func (s ErrorStrategy) String() string
String returns a human-readable representation of s.
type Group ¶ added in v0.1.2
type Group[K comparable, T any] = streaming.Group[K, T]
Group holds one grouping key plus the items assigned to that key.
type Option ¶
Option mutates the execution settings for one transform or terminal call.
func WithDynamicWorkers ¶
func WithDynamicWorkers(controller *ConcurrencyController) Option
WithDynamicWorkers enables graceful dynamic resizing for the current operation. Shrinking does not interrupt workers that already hold a slot.
func WithErrorStrategy ¶
func WithErrorStrategy(strategy ErrorStrategy) Option
WithErrorStrategy configures how worker panics and errors are handled for the current operation.
func WithForcedDynamicWorkers ¶
func WithForcedDynamicWorkers(controller *ConcurrencyController) Option
WithForcedDynamicWorkers enables forced dynamic resizing for the current operation. Shrinking cancels excess workers via context and only works with MapContext or FlatMapContext variants.
func WithInterruptibleWorkers
deprecated
func WithInterruptibleWorkers(controller *ConcurrencyController) Option
WithInterruptibleWorkers is a compatibility alias for WithForcedDynamicWorkers.
Deprecated: use WithForcedDynamicWorkers.
func WithUnlimitedWorkers ¶
func WithUnlimitedWorkers() Option
WithUnlimitedWorkers spawns one worker per item for the current operation.
func WithWorkers ¶
WithWorkers limits the current operation to a fixed number of workers.
type RetryOption ¶
type RetryOption func(*retryOptions)
RetryOption mutates the behavior of one retry call.
func WithAttemptTimeout ¶
func WithAttemptTimeout(timeout time.Duration) RetryOption
WithAttemptTimeout sets a timeout for each individual retry attempt.
func WithIgnoreErrors ¶
func WithIgnoreErrors(ignoreErrors []error) RetryOption
WithIgnoreErrors treats matching errors as successful completion.
func WithInterval ¶
func WithInterval(interval time.Duration) RetryOption
WithInterval sets the delay between failed attempts.
func WithRetry ¶
func WithRetry(times int) RetryOption
WithRetry sets the maximum number of attempts, including the first one.
func WithTimeout ¶
func WithTimeout(timeout time.Duration) RetryOption
WithTimeout sets an overall timeout for the full retry loop.
type Stream ¶
type Stream[T any] struct { // contains filtered or unexported fields }
Stream is a lazy sequence of values backed by a channel plus shared error state that records upstream worker failures.
func Chunk ¶
Chunk groups items into slices of size n, emitting a final short chunk when the source ends.
func Concat ¶
Concat merges s with others and returns a stream that emits items from all inputs as they arrive.
func DistinctBy ¶
func DistinctBy[T any, K comparable](s Stream[T], fn func(T) K) Stream[T]
DistinctBy keeps the first item for each key produced by fn.
func DistinctByCount ¶ added in v0.1.2
func DistinctByCount[T any, K comparable](s Stream[T], n int, fn func(T) K) Stream[T]
DistinctByCount keeps the first item for each key within windows of n input items, resetting the seen-key set after every window.
func DistinctByWindow ¶ added in v0.1.2
func DistinctByWindow[T any, K comparable](ctx context.Context, s Stream[T], every time.Duration, fn func(T) K) Stream[T]
DistinctByWindow keeps the first item for each key within a time window that starts when the first item in that window arrives.
func FlatMapContext ¶
func FlatMapContext[T, U any](ctx context.Context, s Stream[T], fn func(context.Context, T, chan<- U), opts ...Option) Stream[U]
FlatMapContext is FlatMap with a caller-provided context passed into each worker.
func FlatMapContextErr ¶
func FlatMapContextErr[T, U any](ctx context.Context, s Stream[T], fn func(context.Context, T, chan<- U) error, opts ...Option) Stream[U]
FlatMapContextErr is FlatMapErr with a caller-provided context passed into each worker.
func FlatMapErr ¶
FlatMapErr calls fn for each item and records any returned worker error in the stream state.
func FlatStage ¶ added in v0.1.5
func FlatStage[I, O any]( ctx context.Context, in Stream[I], fn func(context.Context, I, chan<- O), opts ...Option, ) Stream[O]
FlatStage applies fn to each item in in and lets fn emit zero or more output values. It is a thin semantic wrapper around FlatMapContext for stage-oriented pipelines.
func FlatStageErr ¶ added in v0.1.5
func FlatStageErr[I, O any]( ctx context.Context, in Stream[I], fn func(context.Context, I, chan<- O) error, opts ...Option, ) Stream[O]
FlatStageErr applies fn to each item in in, lets fn emit zero or more output values, and records returned worker errors in the stream state. It is a thin semantic wrapper around FlatMapContextErr.
func From ¶
From adapts a producer callback into a stream. Panics from generate are captured in the stream state and surfaced by terminal operations.
func GroupBy ¶
func GroupBy[T any, K comparable](s Stream[T], fn func(T) K) Stream[[]T]
GroupBy drains s, groups items by fn, and emits groups in first-seen key order.
func GroupByCount ¶ added in v0.1.2
GroupByCount groups items by fn within windows of n input items and emits one Group per key in first-seen order for each window.
func GroupByWindow ¶ added in v0.1.2
func GroupByWindow[T any, K comparable](ctx context.Context, s Stream[T], every time.Duration, fn func(T) K) Stream[Group[K, T]]
GroupByWindow groups items by fn within a time window that starts when the first item in that window arrives and flushes on timer tick or source close.
func MapContext ¶
func MapContext[T, U any](ctx context.Context, s Stream[T], fn func(context.Context, T) U, opts ...Option) Stream[U]
MapContext is Map with a caller-provided context passed into each worker.
func MapContextErr ¶
func MapContextErr[T, U any](ctx context.Context, s Stream[T], fn func(context.Context, T) (U, error), opts ...Option) Stream[U]
MapContextErr is MapErr with a caller-provided context passed into each worker.
func MapErr ¶
MapErr applies fn to each item in s and records any returned error in the stream state.
func Stage ¶ added in v0.1.5
func Stage[I, O any]( ctx context.Context, in Stream[I], fn func(context.Context, I) O, opts ...Option, ) Stream[O]
Stage applies fn to each item in in and emits the mapped values. It is a thin semantic wrapper around MapContext for pipelines that want explicit stage-shaped call sites without introducing a second runtime model.
func StageErr ¶ added in v0.1.5
func StageErr[I, O any]( ctx context.Context, in Stream[I], fn func(context.Context, I) (O, error), opts ...Option, ) Stream[O]
StageErr applies fn to each item in in and records returned worker errors in the stream state. It is a thin semantic wrapper around MapContextErr for stage-oriented pipelines that still want stream-level error handling.
func Tap ¶ added in v0.1.5
func Tap[T any]( ctx context.Context, in Stream[T], fn func(context.Context, T) error, opts ...Option, ) Stream[T]
Tap runs fn for each item in in and re-emits the original item when fn succeeds. If fn returns an error, Tap records that error in the stream state and does not forward the failed item.
func (Stream[T]) AllMatch ¶
AllMatch reports whether every item satisfies predicate. It drains the remainder of the stream after the first mismatch so delayed fail-fast errors can still surface.
func (Stream[T]) AllMatchErr ¶
AllMatchErr reports whether every item satisfies predicate and returns the current error state when it short-circuits.
func (Stream[T]) AnyMatch ¶
AnyMatch reports whether any item satisfies predicate. It drains the remainder of the stream after the first match so delayed fail-fast errors can still surface.
func (Stream[T]) AnyMatchErr ¶
AnyMatchErr reports whether any item satisfies predicate and returns the current error state when it short-circuits.
func (Stream[T]) Buffer ¶
Buffer inserts a channel buffer of size n between s and the returned stream.
func (Stream[T]) Collect ¶
func (s Stream[T]) Collect() []T
Collect drains the stream into a slice and panics on fail-fast errors.
func (Stream[T]) CollectErr ¶
CollectErr drains the stream into a slice and returns the final error state.
func (Stream[T]) Concat ¶
Concat merges s with others while preserving per-stream item order. Items from different input streams may interleave based on runtime scheduling.
func (Stream[T]) CountErr ¶
CountErr drains the stream, returns the item count, and returns the final error state.
func (Stream[T]) Done ¶
func (s Stream[T]) Done()
Done drains the stream and panics if a fail-fast error was recorded.
func (Stream[T]) Err ¶
Err returns the currently accumulated stream error without draining the stream.
func (Stream[T]) First ¶
First returns the first item and then drains the rest of the stream so any delayed fail-fast error is observed before the call returns.
func (Stream[T]) FirstErr ¶
FirstErr returns the first item and the current error state, then drains the remaining source asynchronously.
func (Stream[T]) ForAll ¶
func (s Stream[T]) ForAll(fn func(<-chan T))
ForAll hands the raw source channel to fn, then drains any leftovers and applies fail-fast panic behavior.
func (Stream[T]) ForAllErr ¶
ForAllErr hands the raw source channel to fn, then drains any leftovers and returns the final error state.
func (Stream[T]) ForEach ¶
func (s Stream[T]) ForEach(fn func(T))
ForEach calls fn for every item in the stream and panics if a fail-fast error was recorded.
func (Stream[T]) ForEachErr ¶
ForEachErr calls fn for every item in the stream and returns the final error state.
func (Stream[T]) Head ¶
Head returns a stream containing at most the first n items from s. The upstream source is drained after the head is satisfied so producers can exit.
func (Stream[T]) LastErr ¶
LastErr drains the stream, returns the last item it observed, and returns the final error state.
func (Stream[T]) MaxErr ¶
MaxErr drains the stream, returns the greatest item according to less, and returns the final error state.
func (Stream[T]) MinErr ¶
MinErr drains the stream, returns the least item according to less, and returns the final error state.
func (Stream[T]) NoneMatch ¶
NoneMatch reports whether no item satisfies predicate. It drains the remainder of the stream after the first match so delayed fail-fast errors can still surface.
func (Stream[T]) NoneMatchErr ¶
NoneMatchErr reports whether no item satisfies predicate and returns the current error state when it short-circuits.
func (Stream[T]) Parallel ¶
Parallel applies fn to each item using the same worker machinery as the transform operators and panics on fail-fast errors.
func (Stream[T]) ParallelErr ¶
ParallelErr applies fn to each item using worker options and returns the final error state.
func (Stream[T]) Reverse ¶
Reverse drains s, reverses the collected items, and replays them as a new stream.
func (Stream[T]) Sort ¶
Sort drains s, sorts all items with less, and then replays them as a new stream.
func (Stream[T]) Tap ¶ added in v0.1.5
func (s Stream[T]) Tap( ctx context.Context, fn func(context.Context, T) error, opts ...Option, ) Stream[T]
Tap runs fn for each item in s and re-emits the original item when fn succeeds.
func (Stream[T]) Through ¶ added in v0.1.5
func (s Stream[T]) Through( ctx context.Context, fn func(context.Context, T) T, opts ...Option, ) Stream[T]
Through applies fn to each item in s and returns another Stream[T]. It exists to make same-type stage segments read fluently in a chain.
func (Stream[T]) ThroughErr ¶ added in v0.1.5
func (s Stream[T]) ThroughErr( ctx context.Context, fn func(context.Context, T) (T, error), opts ...Option, ) Stream[T]
ThroughErr applies fn to each item in s, records returned worker errors in the stream state, and returns another Stream[T]. It exists to make same-type stage segments read fluently in a chain.
type TimeoutOption ¶
TimeoutOption supplies the parent context for a timeout call.
func WithContext ¶
func WithContext(ctx context.Context) TimeoutOption
WithContext sets the parent context for a timeout call.
type WorkerError ¶
type WorkerError struct {
Err error
}
WorkerError wraps a failure produced by one worker goroutine.
func (*WorkerError) Error ¶
func (e *WorkerError) Error() string
Error returns the wrapped worker error text.
func (*WorkerError) Unwrap ¶
func (e *WorkerError) Unwrap() error
Unwrap returns the underlying worker error.