Skip to content

Options & Defaults

Every option constructor ignores invalid zero or negative arguments unless otherwise noted, preserving stage defaults. Passing a nil option value is safe and ignored.

ParOption (Stream.ParMap)

Option Default Invalid / Clamping Rule Behavior
Workers(n int) max(runtime.GOMAXPROCS(0), 1) Ignored when n <= 0 Sets worker pool size. With Workers(1) and no BufferSize, ParMap executes inline without goroutines.
Ordered() Unordered — Reorders emitted items to match upstream input order using a bounded window.
BufferSize(n int) Derived Ignored when n <= 0 Unordered: sets jobs and results channel capacity (default workers). Ordered: sets max in-flight + pending window (default max(workers*2, 16)).

BatchOption (Batch)

Option Default Invalid / Clamping Rule Behavior
MaxSize(n int) 1024 Ignored when n <= 0 Maximum items per batch slice.
MaxWait(d time.Duration) 0 (disabled) Ignored when d <= 0 Maximum wait after the first buffered item before flushing a partial batch. Values > 0 enable the async pump and timer path.

BufferOption (Buffer, BufferDrop)

Option Default Behavior
Block() Default Blocks upstream when queue reaches size.
DropOldest() — Evicts oldest buffered item when full; invokes onDrop(evicted) if non-nil.
DropNewest() — Discards incoming item when full; invokes onDrop(incoming) if non-nil.

Buffer and BufferDrop clamp size < 1 to 1.

RateOption (Stream.RateLimit)

Option Default Invalid / Clamping Rule Behavior
Burst(n int) 1 Ignored when n <= 0 Sets token bucket capacity and initial token count.

Passing perSec <= 0 to RateLimit yields a positive-rate error on iteration ("automi: rate limit must be positive").

RetryOption (Step.Retry)

Option Default Invalid / Clamping Rule Behavior
Multiplier(m float64) 2.0 Ignored when m <= 0 Exponential backoff factor applied between attempts.
MaxDelay(d time.Duration) Unlimited (0) Ignored when d <= 0 Caps computed delay before and after jitter.
Jitter(fraction float64) 0 Clamped to [0, 1] Symmetric random jitter around delay: delay * (1 ± fraction).
RetryIf(pred func(error) bool) Retry non-terminal errors nil resets to default Retries only when pred(err) returns true. Does not override terminal skip/context/circuit exclusions.

Retry clamps attempts < 1 to 1 and initialBackoff < 0 to 0.

ChanOption (ToChan)

Option Default Behavior
CloseOnDone() Keep channel open Closes target channel via defer when Consume exits.

CSVOption (FromCSV, ToCSV)

Option Default Invalid / Clamping Rule Behavior
Comma(r rune) ',' Ignored when r <= 0 Sets CSV field delimiter rune (FromCSV and ToCSV).
SkipHeader() Emit first row — Discards the first non-empty record before yielding rows (FromCSV only).

Fixed Threshold Defaults on Methods

Primitive Parameter Default / Clamping Rule
FromReader chunkSize int Values <= 0 default to 32 * 1024 (32 KiB).
ParEach workers int Values <= 0 default to max(runtime.GOMAXPROCS(0), 1). workers == 1 executes inline.
Take n int Values <= 0 return an empty stream without iterating upstream.
Drop n int Values <= 0 return the stream unchanged.
Debounce d time.Duration Values <= 0 return the stream unchanged.
Step.CircuitBreaker threshold int, resetAfter time.Duration threshold < 1 clamps to 1; resetAfter < 0 clamps to 0.