Documentation
¶
Index ¶
- Variables
- type Caravana
- type Event
- type EventType
- type OnEvent
- type Option
- func WithCloseChannelsOnStop[P any, T any](shouldClose bool) Option[P, T]
- func WithInterval[P any, T any](d time.Duration) Option[P, T]
- func WithMaxRetries[P any, T any](n int) Option[P, T]
- func WithName[P any, T any](name string) Option[P, T]
- func WithOnEvent[P any, T any](cb OnEvent[P, T]) Option[P, T]
- func WithOutput[P any, T any](ch chan T) Option[P, T]
- func WithWorkers[P any, T any](n int) Option[P, T]
- type TaskHolder
Constants ¶
This section is empty.
Variables ¶
var ErrMaxRetriesExceeded = errors.New("max retries exceeded")
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option[P any, T any] func(*TaskHolder[P, T])
Option represents a configuration function used to modify a TaskHolder during construction.
Options are applied by NewTaskHolder to configure optional behavior such as the task name, retry interval, channels, worker count, or logger.
This pattern allows the TaskHolder to be configured in a flexible and extensible way without requiring a large constructor with many parameters.
func WithCloseChannelsOnStop ¶
func WithOutput ¶
type TaskHolder ¶
A TaskHolder reads values of type P from the input channel, executes the configured Task, and optionally emits results of type T to the output channel. Errors returned by the Task are forwarded to the error channel.
Task execution is performed by a configurable number of worker goroutines. Each worker processes items independently, allowing concurrent execution of tasks while preserving a simple pipeline model.
If a Task requests a retry, it will be executed again after the configured interval before completing.
Fields:
name Optional identifier used for logging or debugging. interval Delay applied between retry attempts when a task requests retry. task The function executed for each input value. in Channel from which input values are consumed. out Channel where successful task results are emitted when non-nil. err Channel where task errors are forwarded when non-nil. workers Number of worker goroutines processing the input stream. onEvent Callback for receive events.
func NewTaskHolder ¶
func NewTaskHolderFrom ¶
func (*TaskHolder[P, T]) Start ¶
func (th *TaskHolder[P, T]) Start()
func (*TaskHolder[P, T]) Stop ¶
func (th *TaskHolder[P, T]) Stop()