config

package
v0.1.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultWorkers        = 16
	MinWorkers            = 1
	UnlimitedWorkerBuffer = 4096
)

Variables

View Source
var (
	// ErrNilController reports that a dynamic-worker option received a nil
	// concurrency controller.
	ErrNilController = errors.New("flx: nil concurrency controller")
	// ErrInterruptibleWorkersRequireContextTransform reports that forced dynamic
	// workers were requested for a transform that does not accept a context.
	ErrInterruptibleWorkersRequireContextTransform = errors.New("flx: WithInterruptibleWorkers/WithForcedDynamicWorkers requires MapContext/FlatMapContext")
)
View Source
var ErrInvalidErrorStrategy = errors.New("flx: invalid error strategy")

ErrInvalidErrorStrategy reports that an operation received an unsupported worker error handling mode.

Functions

func MustValidateErrorStrategy

func MustValidateErrorStrategy(strategy ErrorStrategy)

MustValidateErrorStrategy panics when strategy is unsupported.

func ValidateErrorStrategy

func ValidateErrorStrategy(strategy ErrorStrategy) error

ValidateErrorStrategy returns an error when strategy is unsupported.

Types

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
	// ErrorStrategyContinue ignores worker errors and allows the operation to
	// continue without recording them in stream state.
	ErrorStrategyContinue
	// ErrorStrategyLogAndContinue is a deprecated compatibility alias for
	// ErrorStrategyContinue.
	//
	// Deprecated: use ErrorStrategyContinue.
	ErrorStrategyLogAndContinue = ErrorStrategyContinue
)

func (ErrorStrategy) String

func (s ErrorStrategy) String() string

String returns a human-readable representation of s.

type Option

type Option func(*Options)

Option mutates the execution settings for one transform or terminal call.

func WithCoordinator added in v0.1.8

func WithCoordinator(coordinator *coordinatorinternal.Coordinator) Option

WithCoordinator registers one pipeline coordinator to receive runtime snapshots for this operation.

func WithDynamicWorkers

func WithDynamicWorkers(controller *control.Controller) 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 *control.Controller) 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

func WithInterruptibleWorkers(controller *control.Controller) Option

WithInterruptibleWorkers is a compatibility alias for WithForcedDynamicWorkers.

func WithLinkMetricsObserver added in v0.1.8

func WithLinkMetricsObserver(observer link.MetricsObserver) Option

WithLinkMetricsObserver registers the callback that receives link metrics.

func WithStageBudget added in v0.1.8

func WithStageBudget(budget coordinatorinternal.StageBudget) Option

WithStageBudget constrains one coordinator-managed dynamic stage to a worker budget window.

func WithStageMetricsObserver added in v0.1.8

func WithStageMetricsObserver(observer metrics.StageMetricsObserver) Option

WithStageMetricsObserver registers the callback that receives stage metrics.

func WithStageName added in v0.1.8

func WithStageName(name string) Option

WithStageName labels the current transform or terminal operation as one named stage.

func WithUnlimitedWorkers

func WithUnlimitedWorkers() Option

WithUnlimitedWorkers spawns one worker per item for the current operation.

func WithWorkers

func WithWorkers(workers int) Option

WithWorkers limits the current operation to a fixed number of workers.

type Options

type Options struct {
	// contains filtered or unexported fields
}

Options stores execution settings for one transform or terminal operation.

func BuildOptions

func BuildOptions(opts ...Option) *Options

BuildOptions applies opts in order on top of the default settings.

func NewOptions

func NewOptions() *Options

NewOptions returns the default operation settings.

func (*Options) Controller

func (o *Options) Controller() *control.Controller

Controller returns the dynamic concurrency controller, if configured.

func (*Options) Coordinator added in v0.1.8

func (o *Options) Coordinator() *coordinatorinternal.Coordinator

Coordinator returns the configured pipeline coordinator, if any.

func (*Options) ErrorStrategy

func (o *Options) ErrorStrategy() ErrorStrategy

ErrorStrategy returns the worker failure strategy for the operation.

func (*Options) Interruptible

func (o *Options) Interruptible() bool

Interruptible reports whether dynamic worker shrink should cancel workers.

func (*Options) LinkMetricsObserver added in v0.1.8

func (o *Options) LinkMetricsObserver() link.MetricsObserver

LinkMetricsObserver returns the configured observer for link metrics.

func (*Options) ResolveStageName added in v0.1.8

func (o *Options) ResolveStageName() string

ResolveStageName returns the stable stage identity for this operation, generating one when a coordinator is attached and no explicit name was set.

func (*Options) StageBudget added in v0.1.8

func (o *Options) StageBudget() coordinatorinternal.StageBudget

StageBudget returns the configured worker budget for one stage.

func (*Options) StageMetricsObserver added in v0.1.8

func (o *Options) StageMetricsObserver() metrics.StageMetricsObserver

StageMetricsObserver returns the configured observer for stage metrics.

func (*Options) StageName added in v0.1.8

func (o *Options) StageName() string

StageName returns the configured stage identity.

func (*Options) Unlimited

func (o *Options) Unlimited() bool

Unlimited reports whether the operation should spawn one worker per item.

func (*Options) Workers

func (o *Options) Workers() int

Workers returns the configured fixed worker count.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL