Documentation
¶
Index ¶
- func FromChannel[In, Out any](t Task[In, Out], in <-chan In) ([]Out, error)
- func FromSlice[In, Out any](t Task[In, Out], input []In) ([]Out, error)
- func FromValues[In, Out any](t Task[In, Out], input ...In) ([]Out, error)
- type Logger
- type Task
- func Append[T any](s *[]T) Task[T, T]
- func Chain[T any](tasks ...Task[T, T]) Task[T, T]
- func Concurrent[In, Out any](n int, t Task[In, Out]) Task[In, Out]
- func Filter[T any](predicate func(T) (bool, error)) Task[T, T]
- func ForEach[In, Out any](fn func(in In) (Out, error)) Task[In, Out]
- func LogEveryN[T any](n int, logger Logger, msg string, args ...any) Task[T, T]
- func Pipe[A, B, C any](a Task[A, B], b Task[B, C]) Task[A, C]
- func Tee[T any](tee chan<- T) Task[T, T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromChannel ¶ added in v0.3.0
FromChannel starts the task with values from a channel and returns the collected output. Returns a non-nil error if the task fails.
func FromSlice ¶ added in v0.5.0
FromSlice starts the task with the given input slice and returns the collected output. Returns a non-nil error if the task fails.
func FromValues ¶ added in v0.3.0
FromValues starts the task with the given input values and returns the collected output. Returns a non-nil error if the task fails.
Types ¶
type Logger ¶ added in v0.6.0
Logger is the interface used by logging helpers to emit structured log messages.
type Task ¶
Task processes values from in and sends results to out. Must close out when done, including when returning an error. Returning a non-nil error signals that processing has failed; closing the out channel ensures downstream tasks and goroutines terminate cleanly.
func Chain ¶
Chain composes multiple same-type tasks into a single task. If any task in the chain returns an error, it is propagated to the caller.
func Concurrent ¶
Concurrent runs n goroutines of the given task sharing the same in/out channels. If any worker returns an error, the first non-nil error is returned.
func Filter ¶ added in v0.6.0
Filter returns a Task that only forwards items for which predicate returns true. The predicate may also return an error, which will be returned by the Task to abort the pipeline.
func ForEach ¶ added in v0.7.0
ForEach returns a Task that calls fn for each item and forwards the result. The function may also return an error, which will be returned by the Task to abort the pipeline.
func LogEveryN ¶ added in v0.6.0
LogEveryN returns a pass-through Task that logs a message every n items processed.