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
| Class | Purpose |
|---|---|
Semaphore | Limit concurrent access to a shared capacity. |
SemaphorePermit | Release handle returned by Semaphore.acquire(). |
Queue | Run submitted tasks with bounded concurrency. |
QueueOptions | Configure queue concurrency. |
Timing
| Class | Purpose |
|---|---|
RateLimiter | Space queued task starts by a fixed interval. |
RateLimiterOptions | Configure rate limiter interval and queue behavior. |
Timeout | Reject work that does not finish before a timeout. |
Scheduler | Run periodic non-overlapping jobs. |
SchedulerOptions | Configure scheduler interval, task, policy, and semaphore. |
SchedulerErrorPolicy | Enum-style policy for scheduler task failures. |
Debouncer | Collapse repeated calls into the latest task after a quiet period. |
Throttler | Run tasks one at a time with a minimum interval between starts. |
Resilience
| Class | Purpose |
|---|---|
CircuitBreaker | Reject work after repeated failures and probe recovery later. |
CircuitBreakerOptions | Configure thresholds, recovery timeout, and half-open concurrency. |
CircuitBreakerState | Enum-style state object for circuit breaker state. |
Retrier | Retry failing tasks with configured attempts and optional delay. |
RetryOptions | Configure retry attempts and delay. |
Configuration values
These classes are optional. Use them when you want named configuration objects instead of passing numbers directly.
| Class | Purpose |
|---|---|
Concurrency | Positive-integer concurrency limit used by queues and half-open circuit breaker probes. |
SemaphoreCapacity | Positive-integer semaphore capacity. |
CircuitBreakerFailureThreshold | Positive-integer failure threshold. |
CircuitBreakerRecoveryTimeout | Positive-integer recovery timeout. |
CircuitBreakerSuccessThreshold | Positive-integer half-open success threshold. |
RateLimiterInterval | Positive-integer rate-limit interval. |
SchedulerInterval | Positive-integer scheduler interval. |
DebounceDelay | Positive-integer debounce delay. |
ThrottleInterval | Positive-integer throttle interval. |
RetryAttempts | Positive-integer retry attempts. |
RetryDelay | Non-negative retry delay. |
TimeoutDuration | Positive-integer timeout duration. |
Fallbacks and composition
| Class | Purpose |
|---|---|
Flow | Fluent builder for task, timeout, retry, limit, abortability, and existing async controls. |
Racer | Run multiple candidates and resolve with the first success. |
Abortable | Abort running flow work through an AbortSignal. |
FallbackChain | Resolve a value from ordered fallback sources. |
FallbackAttempt | One fallback source inside a chain. |
FlowPipeline | Lower-level composition for classes that expose run(task). |
Errors
See Errors for the full error list and when each one is thrown.