Skip to content

Reference

This section documents the public classes exported from @haskou/flow.

The main API is organized around async tasks: concurrency, timing, retries, dependency protection, fallback resolution, and composition.

Numeric time arguments are interpreted as milliseconds unless a page says otherwise. Most time options also accept Duration from @haskou/value-objects.

Concurrency

ClassPurpose
SemaphoreLimit concurrent access to a shared capacity.
SemaphorePermitRelease handle returned by Semaphore.acquire().
QueueRun submitted tasks with bounded concurrency.
QueueOptionsConfigure queue concurrency.

Timing

ClassPurpose
RateLimiterSpace queued task starts by a fixed interval.
RateLimiterOptionsConfigure rate limiter interval and queue behavior.
TimeoutReject work that does not finish before a timeout.
SchedulerRun periodic non-overlapping jobs.
SchedulerOptionsConfigure scheduler interval, task, policy, and semaphore.
SchedulerErrorPolicyEnum-style policy for scheduler task failures.
DebouncerCollapse repeated calls into the latest task after a quiet period.
ThrottlerRun tasks one at a time with a minimum interval between starts.

Resilience

ClassPurpose
CircuitBreakerReject work after repeated failures and probe recovery later.
CircuitBreakerOptionsConfigure thresholds, recovery timeout, and half-open concurrency.
CircuitBreakerStateEnum-style state object for circuit breaker state.
RetrierRetry failing tasks with configured attempts and optional delay.
RetryOptionsConfigure retry attempts and delay.

Configuration values

These classes are optional. Use them when you want named configuration objects instead of passing numbers directly.

ClassPurpose
ConcurrencyPositive-integer concurrency limit used by queues and half-open circuit breaker probes.
SemaphoreCapacityPositive-integer semaphore capacity.
CircuitBreakerFailureThresholdPositive-integer failure threshold.
CircuitBreakerRecoveryTimeoutPositive-integer recovery timeout.
CircuitBreakerSuccessThresholdPositive-integer half-open success threshold.
RateLimiterIntervalPositive-integer rate-limit interval.
SchedulerIntervalPositive-integer scheduler interval.
DebounceDelayPositive-integer debounce delay.
ThrottleIntervalPositive-integer throttle interval.
RetryAttemptsPositive-integer retry attempts.
RetryDelayNon-negative retry delay.
TimeoutDurationPositive-integer timeout duration.

Fallbacks and composition

ClassPurpose
FlowFluent builder for task, timeout, retry, limit, abortability, and existing async controls.
RacerRun multiple candidates and resolve with the first success.
AbortableAbort running flow work through an AbortSignal.
FallbackChainResolve a value from ordered fallback sources.
FallbackAttemptOne fallback source inside a chain.
FlowPipelineLower-level composition for classes that expose run(task).

Errors

See Errors for the full error list and when each one is thrown.

Released under the MIT License.