Executors
Executors accept task functions through a shared exec() API and apply a scheduling policy. They are useful when several call sites should share the same concurrency, ordering, or protection rules.
Import
Section titled “Import”import { PoolTaskExecutor, RateLimitExecutor } from "@vgerbot/async";import { PoolTaskExecutor } from "@vgerbot/async/executors";Common interface
Section titled “Common interface”interface ITaskExecutor { cancel(reason?: unknown): void; cancel(options: TaskCancelOptions): void; cancel(reason: unknown, options: TaskCancelOptions): void; isCancelled(): boolean; shutdown(reason?: unknown): void; exec<T>(task: AsyncTask<T>, options?: TaskOptions): TaskHandle<T>;}| API | Description |
|---|---|
ITaskExecutor |
Common executor interface. |
PoolTaskExecutor |
Runs submitted tasks with fixed concurrency. |
SeriesTaskExecutor |
Runs submitted tasks one at a time in order. |
PriorityPoolExecutor |
Runs queued tasks by priority with pool concurrency. |
RateLimitExecutor |
Limits how many tasks can start within a time window. |
CircuitBreakerExecutor |
Stops calls temporarily when failures exceed a threshold. |
DebounceTaskExecutor |
Debounces task execution. |
ThrottleTaskExecutor |
Throttles task execution. |
Task options
Section titled “Task options”TaskOptions lets callers label submitted work.
| Option | Description |
|---|---|
kind |
Grouping key used by selective cancellation where supported. |
name |
Human-readable task label for debugging and observability. |
metadata |
Additional caller-provided task metadata. |