Documentation
¶
Overview ¶
Package batch provides generic batch processing capabilities for pocket workflows.
Index ¶
- func Filter[T any](extract func(context.Context, pocket.Store) ([]T, error), ...) pocket.Processor
- func ForEach[T any](extract func(context.Context, pocket.Store) ([]T, error), ...) pocket.Processor
- func MapReduce[T, R any](extract func(context.Context, pocket.Store) ([]T, error), ...) pocket.Processor
- type Option
- type Processor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Filter ¶
func Filter[T any]( extract func(context.Context, pocket.Store) ([]T, error), predicate func(context.Context, T) (bool, error), opts ...Option, ) pocket.Processor
Filter creates a batch processor that filters items.
Types ¶
type Option ¶
type Option func(*options)
Option configures a batch processor.
func WithConcurrency ¶
WithConcurrency sets the maximum concurrent workers.
type Processor ¶
type Processor[T, R any] struct { // Extract retrieves items to process. Extract func(ctx context.Context, store pocket.Store) ([]T, error) // Transform processes a single item. Transform func(ctx context.Context, item T) (R, error) // Reduce combines results into a final output. Reduce func(ctx context.Context, results []R) (any, error) // contains filtered or unexported fields }
Processor processes a batch of items of type T.
Click to show internal directories.
Click to hide internal directories.