dynamic-throttled-queue 2.2.0-rc.1849e68 → 2.2.0-rc.4dd61d6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -26,10 +26,21 @@ throttle(() => {
26
26
  });
27
27
  ```
28
28
 
29
- Callbacks can return `false` to signal an error (used for dynamic rate adjustment and retry). Async callbacks (returning a Promise) are also supported — rejections and `false` resolutions count as errors.
29
+ Callbacks can return `false` to signal a failure (used for dynamic rate adjustment and retry). Async callbacks (returning a Promise) are also supported — rejections and `false` resolutions count as failures. By default, every failure reduces the adaptive rate; use `rateOutcomeClassifier` when only selected failures should do so. Use `retryClassifier` to separately decide whether a failure is eligible for retry.
30
+
31
+ Each callback receives an execution context containing the queue-owned `AbortSignal`. Existing zero-argument callbacks remain supported. Use the signal to cooperatively cancel in-flight work:
32
+
33
+ ```ts
34
+ throttle(async ({ signal }) => {
35
+ const response = await fetch("/api/data", { signal });
36
+ if (!response.ok) return false;
37
+ });
38
+ ```
30
39
 
31
40
  Set `concurrency` to bound callbacks that are still awaiting asynchronous completion. This limit is independent of the request-start rate; omitting it preserves the existing unlimited in-flight behavior.
32
41
 
42
+ Set `maxQueueSize` to bound accepted work. Capacity is reserved from enqueue through terminal success or failure, including pending callbacks, active callbacks, and retries. A full queue makes `enqueue()` throw synchronously in v2; unlimited capacity remains the default. In v3, a full queue will return `false` instead.
43
+
33
44
  ## Options
34
45
 
35
46
  | Param | Type | Default | Description |
@@ -41,12 +52,25 @@ Set `concurrency` to bound callbacks that are still awaiting asynchronous comple
41
52
  | `errors_per_interval` | `number` | `5` | Positive integer error threshold per interval before adjusting rate |
42
53
  | `back_off` | `boolean` | `false` | Back off for 1 full interval when error threshold is hit |
43
54
  | `retry` | `number` | `0` | Non-negative integer number of times to retry failed callbacks |
55
+ | `retryBackoff` | `RetryBackoff` | — | Per-retry fixed, linear, or exponential delay policy; omit for immediate retries |
44
56
  | `concurrency` | `number` | — | Maximum callbacks awaiting asynchronous completion; omit for no limit |
57
+ | `maxQueueSize` | `number` | — | Maximum accepted callbacks not yet terminal, including pending, active, and retried work; omit for no limit |
45
58
  | `compact_threshold` | `number` | `512` | Non-negative integer minimum dead slots before internal queue compaction triggers; `0` compacts at the earliest eligible point |
46
59
  | `rateStrategy` | `RateStrategy` | `linear` | Pure policy that requests the next rate and an optional backoff after each observation window |
60
+ | `rateOutcomeClassifier` | `RateOutcomeClassifier` | — | Decides whether a failed callback outcome contributes to adaptive-rate error counting |
61
+ | `adjustmentTiming` | `"interval" \| "settled"` | `"interval"` | Defines whether rate decisions use outcomes settled each interval or complete started-attempt sets |
62
+ | `retryClassifier` | `RetryClassifier` | — | Decides whether a failed callback outcome is eligible for another attempt |
47
63
  | `onRateChange` | `(rate: number) => void` | — | Called when the current rate changes |
48
64
 
49
- `retry`, `errors_per_interval`, and `compact_threshold` reject fractional and non-finite values. `errors_per_interval` must be at least `1`; `retry` and `compact_threshold` may be `0`.
65
+ `retry`, `errors_per_interval`, `compact_threshold`, and `maxQueueSize` reject fractional and non-finite values. `errors_per_interval` must be at least `1`; `retry` and `compact_threshold` may be `0`. `retryBackoff.baseDelay` and optional `maxDelay` are finite non-negative millisecond values (fractional values are accepted); optional `jitter` is finite from `0` through `1`.
66
+
67
+ `retryBackoff` is `{ strategy: "fixed" | "linear" | "exponential"; baseDelay: number; maxDelay?: number; jitter?: number; random?: () => number }`. The first retry has index `1`: fixed uses `baseDelay`, linear uses `baseDelay × retryIndex`, and exponential uses `baseDelay × 2^(retryIndex - 1)`. The calculated delay is capped at `maxDelay`, when supplied, then optional symmetric percentage jitter is applied and capped again. `random` makes jitter deterministic for tests; a thrown, non-finite, or out-of-range result safely falls back to no jitter. Retry backoff begins when the failed attempt settles and is independent of adaptive-rate `back_off`.
68
+
69
+ ### Adaptive-rate timing
70
+
71
+ `adjustmentTiming: "interval"` is the compatibility default: each configured interval observes the callback outcomes that have settled so far. A slow callback can therefore settle after its start interval and affect a later rate decision.
72
+
73
+ With `adjustmentTiming: "settled"`, an observation window contains every callback attempt that starts during one full configured interval. When collection closes, no further callbacks start until every attempt in that window settles; the queue then makes exactly one rate decision from the complete window. The next collection interval begins immediately after that decision, unless adaptive-rate `back_off` delays scheduling. Empty settled intervals do not produce a decision. A never-settling callback blocks further settled windows until it settles, or until terminal `abort()`.
50
74
 
51
75
  ## Handle API
52
76
 
@@ -54,8 +78,13 @@ Set `concurrency` to bound callbacks that are still awaiting asynchronous comple
54
78
 
55
79
  | Property | Type | Description |
56
80
  | -------- | ---- | ----------- |
81
+ | `pause()` | `() => void` | Temporarily prevent new callback starts while retaining accepted work |
82
+ | `resume()` | `() => void` | Resume a paused queue with a fresh pacing and observation window |
57
83
  | `stop()` | `() => void` | Stop processing the queue immediately |
58
- | `pending` | `number` (readonly) | Number of callbacks still waiting in the queue |
84
+ | `abort()` | `() => void` | Terminally discard queued work and signal active callbacks |
85
+ | `waitForIdle()` | `() => Promise<void>` | Resolves when all pending, active, and delayed-retry work has completed |
86
+ | `getState()` | `() => QueueState` | Returns a frozen point-in-time snapshot of queue state and counters |
87
+ | `pending` | `number` (readonly) | Number of callbacks waiting in the queue, including delayed retries |
59
88
 
60
89
  ```ts
61
90
  const throttle = createThrottledQueue({ min_rpi: 5, interval: 1000 });
@@ -66,7 +95,26 @@ console.log(throttle.pending); // number of queued callbacks
66
95
  throttle.stop(); // halt processing
67
96
  ```
68
97
 
69
- `stop()` clears scheduler timers and retains callbacks that have not started. It cannot cancel an active asynchronous callback; if that callback later succeeds, returns `false`, or rejects, its settlement does not restart scheduling. A retry created by a failed active callback is retained with the pending work. Enqueueing another callback resumes the queue.
98
+ ## Lifecycle
99
+
100
+ | State | Pending work and enqueue | Active work | Scheduling and lifecycle operations |
101
+ | ----- | ------------------------ | ----------- | ----------------------------------- |
102
+ | Running | Pending work can start; new callbacks are accepted. | Continues normally. | `pause()` retains work and stops new starts. `stop()` retains work and clears timers. `abort()` is terminal. |
103
+ | Paused | Pending work, newly enqueued callbacks, and retries are retained but do not start. | Continues and settles normally. | `resume()` restarts pacing at the current rate and begins a fresh adaptive-rate observation window. Delayed retries freeze their remaining delay and continue only after resume. `pause()` is idempotent. `stop()` clears the paused state. |
104
+ | Stopped | Pending work is retained. A later enqueue restarts scheduling. | Continues and settles normally. | Delayed retries freeze their remaining delay; the later enqueue resumes them. `pause()` and `resume()` are no-ops. `stop()` is idempotent. |
105
+ | Aborted | Pending work is discarded and future enqueues throw. | Receives the shared abort signal and may finish cooperatively. | `pause()`, `resume()`, `stop()`, and `abort()` do not restart scheduling; `abort()` is idempotent. |
106
+
107
+ While paused, callback outcomes do not contribute to adaptive-rate adjustment. A failed active callback may still create a configured retry, but that retry remains pending until `resume()`.
108
+
109
+ In settled timing, `pause()` discards the in-progress observation window rather than making a partial or late rate decision. `stop()` retains its non-restarting behavior, and `abort()` remains terminal: neither produces post-stop or post-abort settled-window accounting.
110
+
111
+ `stop()` clears scheduler timers and retains callbacks that have not started. It cannot cancel an active asynchronous callback; if that callback later succeeds, returns `false`, or rejects, its settlement does not restart scheduling. A retry created by a failed active callback is retained with the pending work. Enqueueing another callback resumes the queue and any frozen delayed retries.
112
+
113
+ `abort()` is terminal and idempotent. It clears scheduler timers, discards pending callbacks, and aborts the one shared signal supplied to active callbacks. Future enqueue attempts throw. Cancellation is cooperative: callbacks that ignore the signal can continue running, but their later success or failure does not retry work or affect adaptive-rate accounting.
114
+
115
+ `getState()` returns a frozen `QueueState` snapshot. Each call is independent; mutations to the returned object do not affect the queue. Fields: `rate` (current rate), `pending` (queued + delayed retries), `active` (callbacks executing), `state` (`"running"` | `"paused"` | `"stopped"` | `"aborted"`), and monotonic lifetime counters `started`, `succeeded`, `failed`, `retried`, `rateIncreases`, `rateDecreases`. `started`/`succeeded`/`failed` count callback attempts: a retry is a new attempt; a failure is counted even when a later retry succeeds. `retried` increments only when another attempt is actually scheduled. Rate-direction counters match applied rate changes and `onRateChange` notifications exactly. Counters do not change for settlements after `abort()`.
116
+
117
+ `waitForIdle()` returns a `Promise<void>` that resolves once all pending callbacks, active executions, and delayed retries have reached a terminal outcome. If the queue is already idle the promise resolves immediately. Each call is one-shot: a later enqueue does not affect a promise that has already resolved. Multiple simultaneous callers all resolve at the same idle transition without retaining waiter state. A callback failure that triggers a retry never exposes a transient idle transition between the failed attempt and the retry. `stop()` retains pending work, so existing waiters remain pending until that work completes after a later enqueue resumes the queue. `abort()` discards pending work but waiters remain pending until every active callback settles; post-abort settlements do not create new retry work. A paused queue resolves waiters only when both pending and active work are zero.
70
118
 
71
119
  ## Examples
72
120
 
@@ -118,9 +166,69 @@ for (let i = 0; i < 100; i++) {
118
166
  }
119
167
  ```
120
168
 
169
+ ### Rate outcome classification
170
+
171
+ `rateOutcomeClassifier` receives only failed callback outcomes and returns whether each one should reduce the adaptive rate. It does not change retry eligibility: `false`, thrown errors, and rejected promises still retry under the existing `retry` option.
172
+
173
+ ```ts
174
+ import {
175
+ createThrottledQueue,
176
+ type RateFailureOutcome,
177
+ } from "dynamic-throttled-queue";
178
+
179
+ function affectsCapacity(outcome: RateFailureOutcome) {
180
+ if (outcome.kind === "returned-false") return false;
181
+
182
+ // Treat HTTP 429 and 5xx as capacity signals, while ignoring other failures.
183
+ const status = (outcome.error as { status?: number }).status;
184
+ return status === 429 || (status !== undefined && status >= 500 && status < 600);
185
+ }
186
+
187
+ const throttle = createThrottledQueue({
188
+ min_rpi: 1,
189
+ max_rpi: 10,
190
+ interval: 1000,
191
+ rateOutcomeClassifier: affectsCapacity,
192
+ });
193
+ ```
194
+
195
+ The normalized outcomes are `{ kind: "returned-false" }`, `{ kind: "thrown", error }`, and `{ kind: "rejected", error }`. Omitting the classifier preserves the default behavior: every failure reduces the adaptive rate. If the classifier throws, the original failure safely counts as rate-reducing and no separate classifier error is surfaced.
196
+
197
+ ### Retry classification
198
+
199
+ `retryClassifier` receives the same normalized failure outcome and a one-based attempt number, including the initial callback start. It must return literal `true` for the failure to be retried; any other value makes it permanent. The configured `retry` value remains the hard cap on additional attempts, so the classifier is not called after that budget is exhausted. If it throws, the queue preserves legacy behavior and retries subject to the remaining budget.
200
+
201
+ Retry eligibility is independent from adaptive-rate accounting. A failure can be retryable, rate-reducing, both, or neither:
202
+
203
+ ```ts
204
+ const throttle = createThrottledQueue({
205
+ min_rpi: 1,
206
+ interval: 1000,
207
+ retry: 2,
208
+ retryClassifier: (outcome, attempt) =>
209
+ outcome.kind === "rejected" && attempt < 3,
210
+ rateOutcomeClassifier: outcome => outcome.kind === "rejected",
211
+ });
212
+ ```
213
+
121
214
  ### Rate strategies
122
215
 
123
- The default `linear` strategy preserves the adaptive behavior above. You can import and pass it explicitly, or provide a custom pure strategy:
216
+ The default `linear` strategy preserves the adaptive behavior above: it changes the rate by one request per interval. Use `aimd` when a capacity signal should reduce throughput more quickly while recovery remains gradual. AIMD increases by a fixed amount after a clean eligible observation window and reduces the rate by a multiplier when the error threshold is reached.
217
+
218
+ ```ts
219
+ import { aimd, createThrottledQueue } from "dynamic-throttled-queue";
220
+
221
+ const throttle = createThrottledQueue({
222
+ min_rpi: 1,
223
+ max_rpi: 100,
224
+ interval: 1000,
225
+ rateStrategy: aimd({ increaseBy: 2, decreaseFactor: 0.5 }),
226
+ });
227
+ ```
228
+
229
+ `aimd()` defaults to `{ increaseBy: 1, decreaseFactor: 0.5 }`. `increaseBy` must be a positive integer; `decreaseFactor` must be greater than `0` and less than `1`. AIMD uses `Math.floor(currentRate * decreaseFactor)` when reducing the rate, then the queue applies its configured `min_rpi` and `max_rpi` bounds. Like `linear`, it holds steady for partial-error, empty, and immediately-post-backoff observation windows.
230
+
231
+ You can also import and pass `linear` explicitly, or provide a custom pure strategy:
124
232
 
125
233
  ```ts
126
234
  import {
@@ -180,6 +288,24 @@ throttle(async () => {
180
288
  });
181
289
  ```
182
290
 
291
+ ### Retry backoff
292
+
293
+ ```ts
294
+ const throttle = createThrottledQueue({
295
+ min_rpi: 5,
296
+ interval: 1000,
297
+ retry: 3,
298
+ retryBackoff: {
299
+ strategy: "exponential",
300
+ baseDelay: 250,
301
+ maxDelay: 10_000,
302
+ jitter: 0.2,
303
+ },
304
+ });
305
+ ```
306
+
307
+ Delayed retries remain pending, return to the normal queue tail when due, and then obey normal scheduler pacing. Equal due times preserve the order their retry delays were scheduled. `abort()` discards delayed retries along with other pending work.
308
+
183
309
  ## Migration from v1
184
310
 
185
311
  - `errors_per_second` removed — use `errors_per_interval` (counts errors per full interval window, not per second).
@@ -1,3 +1,10 @@
1
+ export type RetryBackoff = {
2
+ strategy: "fixed" | "linear" | "exponential";
3
+ baseDelay: number;
4
+ maxDelay?: number;
5
+ jitter?: number;
6
+ random?: () => number;
7
+ };
1
8
  export type RateStrategyObservation = Readonly<{
2
9
  currentRate: number;
3
10
  minRate: number;
@@ -12,9 +19,29 @@ export type RateStrategyDecision = Readonly<{
12
19
  shouldBackOff: boolean;
13
20
  }>;
14
21
  export type RateStrategy = (observation: RateStrategyObservation) => RateStrategyDecision;
22
+ export type AimdOptions = {
23
+ increaseBy?: number;
24
+ decreaseFactor?: number;
25
+ };
26
+ export type RateFailureOutcome = Readonly<{
27
+ kind: "returned-false";
28
+ }> | Readonly<{
29
+ kind: "thrown";
30
+ error: unknown;
31
+ }> | Readonly<{
32
+ kind: "rejected";
33
+ error: unknown;
34
+ }>;
35
+ export type RateOutcomeClassifier = (outcome: RateFailureOutcome) => boolean;
36
+ export type RetryClassifier = (outcome: RateFailureOutcome, attempt: number) => boolean;
37
+ export type AdjustmentTiming = "interval" | "settled";
15
38
  export declare const linear: RateStrategy;
39
+ export declare function aimd({ increaseBy, decreaseFactor }?: AimdOptions): RateStrategy;
40
+ export type ExecutionContext = Readonly<{
41
+ signal: AbortSignal;
42
+ }>;
16
43
  /** Return `false` to signal failure (increments error count, triggers retry if configured). */
17
- export type ThrottleCallback = () => boolean | void | Promise<boolean | void>;
44
+ export type ThrottleCallback = (context: ExecutionContext) => boolean | void | Promise<boolean | void>;
18
45
  export type ThrottleOptions = {
19
46
  min_rpi: number;
20
47
  interval: number;
@@ -25,17 +52,45 @@ export type ThrottleOptions = {
25
52
  back_off?: boolean;
26
53
  /** Non-negative integer retries for each failed callback. Default 0. */
27
54
  retry?: number;
55
+ /** Per-retry delay policy. Omit to preserve immediate retries. */
56
+ retryBackoff?: RetryBackoff;
28
57
  /** Maximum number of callbacks awaiting asynchronous settlement. Omit for no limit. */
29
58
  concurrency?: number;
59
+ /** Maximum accepted callbacks that have not reached a terminal outcome. Omit for no limit. */
60
+ maxQueueSize?: number;
30
61
  /** Non-negative integer dead slots before queue compaction triggers. Default 512. */
31
62
  compact_threshold?: number;
32
63
  /** Policy used to request the next rate and any backoff after each observation window. */
33
64
  rateStrategy?: RateStrategy;
65
+ /** Decides whether a failed callback outcome contributes to adaptive-rate error counting. */
66
+ rateOutcomeClassifier?: RateOutcomeClassifier;
67
+ /** Decides whether a failed callback outcome is eligible for another attempt. */
68
+ retryClassifier?: RetryClassifier;
69
+ /** When adaptive-rate observations are adjusted. Defaults to interval compatibility behavior. */
70
+ adjustmentTiming?: AdjustmentTiming;
34
71
  onRateChange?: (rate: number) => void;
35
72
  };
36
73
  export type ThrottleFn = (callback: ThrottleCallback) => void;
74
+ export type QueueLifecycleState = "running" | "paused" | "stopped" | "aborted";
75
+ export type QueueState = Readonly<{
76
+ rate: number;
77
+ pending: number;
78
+ active: number;
79
+ state: QueueLifecycleState;
80
+ started: number;
81
+ succeeded: number;
82
+ failed: number;
83
+ retried: number;
84
+ rateIncreases: number;
85
+ rateDecreases: number;
86
+ }>;
37
87
  export type ThrottleHandle = ThrottleFn & {
88
+ pause: () => void;
89
+ resume: () => void;
38
90
  stop: () => void;
91
+ abort: () => void;
92
+ waitForIdle: () => Promise<void>;
93
+ getState: () => QueueState;
39
94
  readonly pending: number;
40
95
  };
41
96
  export declare function createThrottledQueue(options: ThrottleOptions): ThrottleHandle;
@@ -1,5 +1,6 @@
1
1
  import { createRateController } from "./rate-controller.js";
2
2
  import { createScheduler } from "./scheduler.js";
3
+ const adjustmentTimings = new Set(["interval", "settled"]);
3
4
  export const linear = ({ minRate, maxRate, currentRate, errorCount, errorThreshold, hasPendingWork, wasBackedOff, }) => {
4
5
  if (errorCount >= errorThreshold) {
5
6
  return { nextRate: Math.max(minRate, currentRate - 1), shouldBackOff: true };
@@ -9,8 +10,38 @@ export const linear = ({ minRate, maxRate, currentRate, errorCount, errorThresho
9
10
  }
10
11
  return { nextRate: currentRate, shouldBackOff: false };
11
12
  };
13
+ export function aimd({ increaseBy = 1, decreaseFactor = 0.5 } = {}) {
14
+ if (!Number.isInteger(increaseBy) || increaseBy < 1) {
15
+ throw new Error("increaseBy must be a positive integer");
16
+ }
17
+ if (!Number.isFinite(decreaseFactor) || decreaseFactor <= 0 || decreaseFactor >= 1) {
18
+ throw new Error("decreaseFactor must be a number greater than 0 and less than 1");
19
+ }
20
+ return ({ currentRate, errorCount, errorThreshold, hasPendingWork, wasBackedOff }) => {
21
+ if (errorCount >= errorThreshold) {
22
+ return { nextRate: Math.floor(currentRate * decreaseFactor), shouldBackOff: true };
23
+ }
24
+ if (!wasBackedOff && errorCount === 0 && hasPendingWork) {
25
+ return { nextRate: currentRate + increaseBy, shouldBackOff: false };
26
+ }
27
+ return { nextRate: currentRate, shouldBackOff: false };
28
+ };
29
+ }
30
+ function validateRetryBackoff(retryBackoff) {
31
+ if (retryBackoff === undefined)
32
+ return;
33
+ if (!Number.isFinite(retryBackoff.baseDelay) || retryBackoff.baseDelay < 0) {
34
+ throw new Error("retryBackoff.baseDelay must be a finite non-negative number");
35
+ }
36
+ if (retryBackoff.maxDelay !== undefined && (!Number.isFinite(retryBackoff.maxDelay) || retryBackoff.maxDelay < 0)) {
37
+ throw new Error("retryBackoff.maxDelay must be a finite non-negative number");
38
+ }
39
+ if (retryBackoff.jitter !== undefined && (!Number.isFinite(retryBackoff.jitter) || retryBackoff.jitter < 0 || retryBackoff.jitter > 1)) {
40
+ throw new Error("retryBackoff.jitter must be a finite number from 0 through 1");
41
+ }
42
+ }
12
43
  export function createThrottledQueue(options) {
13
- const { min_rpi, interval, max_rpi = min_rpi, concurrency, retry = 0, compact_threshold = 512 } = options;
44
+ const { min_rpi, interval, max_rpi = min_rpi, concurrency, maxQueueSize, retry = 0, compact_threshold = 512 } = options;
14
45
  const errors_per_interval = options.errors_per_interval ?? 5;
15
46
  if (!Number.isInteger(min_rpi) || min_rpi < 1) {
16
47
  throw new Error("min_rpi must be a positive integer");
@@ -24,6 +55,9 @@ export function createThrottledQueue(options) {
24
55
  if (concurrency !== undefined && (!Number.isInteger(concurrency) || concurrency < 1)) {
25
56
  throw new Error("concurrency must be a positive integer");
26
57
  }
58
+ if (maxQueueSize !== undefined && (!Number.isSafeInteger(maxQueueSize) || maxQueueSize < 0)) {
59
+ throw new Error("maxQueueSize must be a non-negative safe integer");
60
+ }
27
61
  if (!Number.isInteger(errors_per_interval) || errors_per_interval < 1) {
28
62
  throw new Error("errors_per_interval must be a positive integer");
29
63
  }
@@ -33,6 +67,10 @@ export function createThrottledQueue(options) {
33
67
  if (!Number.isInteger(compact_threshold) || compact_threshold < 0) {
34
68
  throw new Error("compact_threshold must be a non-negative integer");
35
69
  }
70
+ if (options.adjustmentTiming !== undefined && !adjustmentTimings.has(options.adjustmentTiming)) {
71
+ throw new Error("adjustmentTiming must be either interval or settled");
72
+ }
73
+ validateRetryBackoff(options.retryBackoff);
36
74
  return createScheduler(options, createRateController({
37
75
  min_rpi,
38
76
  max_rpi,
@@ -1 +1 @@
1
- {"version":3,"file":"dynamic-throttled-queue.js","sourceRoot":"","sources":["../src/dynamic-throttled-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,6BAA6B;AAC5D,OAAO,EAAE,eAAe,EAAE,uBAAuB;AAmBjD,MAAM,CAAC,MAAM,MAAM,GAAiB,CAAC,EACnC,OAAO,EACP,OAAO,EACP,WAAW,EACX,UAAU,EACV,cAAc,EACd,cAAc,EACd,YAAY,GACb,EAAE,EAAE;IACH,IAAI,UAAU,IAAI,c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S,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC/F,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IACD,oBAAoB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAC3C,OAAO,eAAe,CAAC,OAAO,EAAE,oBAAoB,CAAC;QACnD,OAAO;QACP,OAAO;QACP,mBAAmB;KACpB,EAAE,OAAO,CAAC,YAAY,IAAI,MAAM,CAAC,CAAC,CAAC;AACtC,CAAC"}
@@ -14,7 +14,8 @@ export type RateDecision = {
14
14
  };
15
15
  export type RateController = {
16
16
  readonly rate: number;
17
- recordCompletion: (result: boolean | void) => void;
17
+ clearObservation: () => void;
18
+ recordCompletion: (isRateReducing: boolean) => void;
18
19
  observe: (observation: Observation) => RateDecision;
19
20
  };
20
21
  export declare function createRateController(options: RateControllerOptions, strategy: RateStrategy): RateController;
@@ -18,8 +18,11 @@ export function createRateController(options, strategy) {
18
18
  get rate() {
19
19
  return rate;
20
20
  },
21
- recordCompletion(result) {
22
- if (result === false)
21
+ clearObservation() {
22
+ errorCount = 0;
23
+ },
24
+ recordCompletion(isRateReducing) {
25
+ if (isRateReducing)
23
26
  errorCount++;
24
27
  },
25
28
  observe(observation) {
@@ -1 +1 @@
1
- {"version":3,"file":"rate-controller.js","sourceRoot":"","sources":["../src/rate-controller.ts"],"names":[],"mappings":"AAwBA,SAAS,gBAAgB,CAAC,QAAiB;IACzC,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtD,MAAM,IAAI,SAAS,CAAC,6CAA6C,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,SAAS,GAAG,QAAgC,CAAC;IACnD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,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BACxB,UAAU;gBACV,cAAc,EAAE,OAAO,CAAC,mBAAmB;gBAC3C,GAAG,WAAW;aACf,CAAC,CAAC,CAAC,CAAC;YACL,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC/E,UAAU,GAAG,CAAC,CAAC;YACf,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,CAAC,aAAa,EAAE,CAAC;QACzD,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { RetryBackoff } from "./dynamic-throttled-queue.js";
2
+ export declare function calculateRetryDelay(policy: RetryBackoff, retryIndex: number): number;
@@ -0,0 +1,31 @@
1
+ function readRandom(random) {
2
+ try {
3
+ // eslint-disable-next-line sonarjs/pseudo-random -- Default jitter requires a random source.
4
+ const value = random?.() ?? Math.random();
5
+ return Number.isFinite(value) && value >= 0 && value <= 1 ? value : undefined;
6
+ }
7
+ catch {
8
+ return undefined;
9
+ }
10
+ }
11
+ export function calculateRetryDelay(policy, retryIndex) {
12
+ let delay;
13
+ switch (policy.strategy) {
14
+ case "linear":
15
+ delay = policy.baseDelay * retryIndex;
16
+ break;
17
+ case "exponential":
18
+ delay = policy.baseDelay * 2 ** (retryIndex - 1);
19
+ break;
20
+ default: delay = policy.baseDelay;
21
+ }
22
+ const cappedDelay = policy.maxDelay === undefined ? delay : Math.min(delay, policy.maxDelay);
23
+ if (policy.jitter === undefined)
24
+ return cappedDelay;
25
+ const random = readRandom(policy.random);
26
+ if (random === undefined)
27
+ return cappedDelay;
28
+ const jitteredDelay = cappedDelay * (1 + (random * 2 - 1) * policy.jitter);
29
+ return policy.maxDelay === undefined ? jitteredDelay : Math.min(jitteredDelay, policy.maxDelay);
30
+ }
31
+ //# sourceMappingURL=retry-backoff.js.map
@@ -0,0 +1 @@
1
+ {"version":3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C,GAAG,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC3E,OAAO,MAAM,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;AAClG,CAAC"}
package/dist/scheduler.js CHANGED
@@ -1,5 +1,7 @@
1
+ import { calculateRetryDelay } from "./retry-backoff.js";
1
2
  export function createScheduler(options, rateController) {
2
- const { interval, evenly_spaced = true, retry = 0, concurrency, compact_threshold = 512, back_off = false, onRateChange, } = options;
3
+ const { interval, evenly_spaced = true, retry = 0, retryBackoff, concurrency, maxQueueSize, compact_threshold = 512, back_off = false, rateOutcomeClassifier, retryClassifier, onRateChange, adjustmentTiming = "interval", } = options;
4
+ const usesSettledTiming = adjustmentTiming === "settled";
3
5
  let current_rpi = rateController.rate;
4
6
  let dyn_interval = evenly_spaced ? interval / current_rpi : interval;
5
7
  let dyn_requests_per_interval = evenly_spaced ? 1 : current_rpi;
@@ -9,12 +11,77 @@ export function createScheduler(options, rateController) {
9
11
  let timeout;
10
12
  let dynTimeout;
11
13
  let active_count = 0;
14
+ let isPaused = false;
12
15
  let isStopped = false;
16
+ let isAborted = false;
13
17
  let hasStrategyFailure = false;
18
+ let cnt_started = 0;
19
+ let cnt_succeeded = 0;
20
+ let cnt_failed = 0;
21
+ let cnt_retried = 0;
22
+ let cnt_rateIncreases = 0;
23
+ let cnt_rateDecreases = 0;
14
24
  let strategyFailure;
25
+ const abortController = new AbortController();
15
26
  const max_concurrency = concurrency ?? Infinity;
27
+ const max_queue_size = maxQueueSize ?? Infinity;
16
28
  const queue = [];
29
+ const delayedRetries = [];
17
30
  let head = 0;
31
+ let reserved_count = 0;
32
+ let observationWindow;
33
+ let nextObservationWindow = 0;
34
+ let collectingSettledWindow = false;
35
+ let settledOutstanding = 0;
36
+ const idleWaiters = [];
37
+ function isIdle() {
38
+ return active_count === 0 && queue.length <= head && delayedRetries.length === 0;
39
+ }
40
+ function notifyIdle() {
41
+ if (!isIdle())
42
+ return;
43
+ const waiters = idleWaiters.splice(0);
44
+ for (const resolve of waiters)
45
+ resolve();
46
+ }
47
+ function releaseDelayedRetry(delayedRetry) {
48
+ const index = delayedRetries.indexOf(delayedRetry);
49
+ if (index < 0)
50
+ return;
51
+ delayedRetries.splice(index, 1);
52
+ queue.push(delayedRetry.item);
53
+ if (!isRunning && !isPaused && !isStopped && queue.length > head)
54
+ start();
55
+ }
56
+ function startDelayedRetry(delayedRetry) {
57
+ delayedRetry.due = Date.now() + delayedRetry.remaining;
58
+ delayedRetry.timeout = setTimeout(() => {
59
+ releaseDelayedRetry(delayedRetry);
60
+ }, delayedRetry.remaining);
61
+ }
62
+ function freezeDelayedRetries() {
63
+ for (const delayedRetry of delayedRetries) {
64
+ if (delayedRetry.timeout === undefined)
65
+ continue;
66
+ if (delayedRetry.due === undefined)
67
+ continue;
68
+ clearTimeout(delayedRetry.timeout);
69
+ delayedRetry.timeout = undefined;
70
+ delayedRetry.remaining = Math.max(0, delayedRetry.due - Date.now());
71
+ }
72
+ }
73
+ function resumeDelayedRetries() {
74
+ for (const delayedRetry of delayedRetries) {
75
+ if (delayedRetry.timeout === undefined)
76
+ startDelayedRetry(delayedRetry);
77
+ }
78
+ }
79
+ function scheduleDelayedRetry(item, delay) {
80
+ const delayedRetry = { item, remaining: delay };
81
+ delayedRetries.push(delayedRetry);
82
+ if (!isPaused && !isStopped)
83
+ startDelayedRetry(delayedRetry);
84
+ }
18
85
  function halt() {
19
86
  isRunning = false;
20
87
  skippedLast = false;
@@ -27,23 +94,126 @@ export function createScheduler(options, rateController) {
27
94
  head = 0;
28
95
  }
29
96
  }
97
+ function discardSettledWindow() {
98
+ observationWindow = undefined;
99
+ collectingSettledWindow = false;
100
+ settledOutstanding = 0;
101
+ }
30
102
  function stop() {
31
103
  isStopped = true;
104
+ isPaused = false;
105
+ freezeDelayedRetries();
106
+ halt();
107
+ discardSettledWindow();
108
+ }
109
+ function pause() {
110
+ if (isAborted || isStopped || isPaused)
111
+ return;
112
+ isPaused = true;
113
+ rateController.clearObservation();
114
+ freezeDelayedRetries();
115
+ halt();
116
+ discardSettledWindow();
117
+ }
118
+ function resume() {
119
+ if (!isPaused)
120
+ return;
121
+ isPaused = false;
122
+ resumeDelayedRetries();
123
+ if (queue.length > head)
124
+ start();
125
+ }
126
+ function abort() {
127
+ if (isAborted)
128
+ return;
129
+ isAborted = true;
32
130
  halt();
131
+ discardSettledWindow();
132
+ freezeDelayedRetries();
133
+ delayedRetries.length = 0;
134
+ queue.length = 0;
135
+ head = 0;
136
+ reserved_count = 0;
137
+ abortController.abort();
33
138
  }
34
- function handleResult(item, result) {
35
- rateController.recordCompletion(result);
36
- if (result === false && item.retries > 0) {
37
- queue.push({ fn: item.fn, retries: item.retries - 1 });
38
- if (!isRunning && !isStopped && queue.length > head)
39
- start();
139
+ function isRateReducing(outcome) {
140
+ if (!outcome)
141
+ return false;
142
+ try {
143
+ return rateOutcomeClassifier?.(outcome) ?? true;
144
+ }
145
+ catch {
146
+ return true;
147
+ }
148
+ }
149
+ function isRetryable(item, outcome) {
150
+ if (!outcome || item.retries === 0)
151
+ return false;
152
+ try {
153
+ return retryClassifier ? retryClassifier(outcome, retry - item.retries + 1) === true : true;
154
+ }
155
+ catch {
156
+ return true;
157
+ }
158
+ }
159
+ function handleResult(item, outcome) {
160
+ if (isAborted)
161
+ return;
162
+ if (outcome)
163
+ cnt_failed++;
164
+ else
165
+ cnt_succeeded++;
166
+ if (!isPaused && (!usesSettledTiming || item.observationWindow === observationWindow)) {
167
+ rateController.recordCompletion(isRateReducing(outcome));
168
+ }
169
+ if (isRetryable(item, outcome)) {
170
+ cnt_retried++;
171
+ const retryItem = { fn: item.fn, retries: item.retries - 1 };
172
+ if (retryBackoff === undefined) {
173
+ queue.push(retryItem);
174
+ if (!isRunning && !isPaused && !isStopped && queue.length > head)
175
+ start();
176
+ }
177
+ else {
178
+ const retryIndex = retry - item.retries + 1;
179
+ scheduleDelayedRetry(retryItem, calculateRetryDelay(retryBackoff, retryIndex));
180
+ }
40
181
  }
182
+ else
183
+ reserved_count--;
41
184
  }
42
- function handleSettlement(item, result, resume = false) {
185
+ function handleSettlement(item, outcome, resume = false) {
43
186
  active_count--;
44
- handleResult(item, result);
45
- if (resume && isRunning && !skippedLast && queue.length > head)
187
+ handleResult(item, outcome);
188
+ if (item.observationWindow === observationWindow) {
189
+ settledOutstanding--;
190
+ if (!collectingSettledWindow && settledOutstanding === 0)
191
+ finishSettledWindow();
192
+ }
193
+ if (resume && isRunning && !skippedLast && queue.length > head && (!usesSettledTiming || collectingSettledWindow))
46
194
  dequeue();
195
+ notifyIdle();
196
+ }
197
+ function execute(item) {
198
+ if (usesSettledTiming && collectingSettledWindow) {
199
+ item.observationWindow = observationWindow;
200
+ settledOutstanding++;
201
+ }
202
+ cnt_started++;
203
+ active_count++;
204
+ let result;
205
+ try {
206
+ result = item.fn({ signal: abortController.signal });
207
+ }
208
+ catch (error) {
209
+ handleSettlement(item, { kind: "thrown", error });
210
+ return;
211
+ }
212
+ if (result instanceof Promise) {
213
+ void result.then(value => handleSettlement(item, value === false ? { kind: "returned-false" } : undefined, true), (error) => handleSettlement(item, { kind: "rejected", error }, true));
214
+ return;
215
+ }
216
+ handleSettlement(item, result === false ? { kind: "returned-false" } : undefined);
47
217
  }
48
218
  function dequeue() {
49
219
  const threshold = last_called + dyn_interval;
@@ -57,29 +227,15 @@ export function createScheduler(options, rateController) {
57
227
  let started = 0;
58
228
  while (head < end && active_count < max_concurrency) {
59
229
  const item = queue[head++];
60
- active_count++;
61
230
  if (started++ === 0)
62
231
  last_called = Date.now();
63
- let result;
64
- try {
65
- result = item.fn();
66
- }
67
- catch {
68
- handleSettlement(item, false);
69
- continue;
70
- }
71
- if (result instanceof Promise) {
72
- void result.then(value => handleSettlement(item, value, true), () => handleSettlement(item, false, true));
73
- }
74
- else {
75
- handleSettlement(item, result);
76
- }
232
+ execute(item);
77
233
  }
78
234
  if (head > compact_threshold && head > queue.length / 2) {
79
235
  queue.splice(0, head);
80
236
  head = 0;
81
237
  }
82
- if (head >= queue.length) {
238
+ if (head >= queue.length && !usesSettledTiming) {
83
239
  halt();
84
240
  return;
85
241
  }
@@ -90,6 +246,10 @@ export function createScheduler(options, rateController) {
90
246
  function applyRate(newRpi) {
91
247
  if (newRpi === current_rpi)
92
248
  return;
249
+ if (newRpi > current_rpi)
250
+ cnt_rateIncreases++;
251
+ else
252
+ cnt_rateDecreases++;
93
253
  current_rpi = newRpi;
94
254
  onRateChange?.(current_rpi);
95
255
  if (evenly_spaced)
@@ -120,9 +280,67 @@ export function createScheduler(options, rateController) {
120
280
  if (isRunning)
121
281
  dynTimeout = setTimeout(adjustRate, interval);
122
282
  }
283
+ function finishSettledWindow() {
284
+ if (observationWindow === undefined || isPaused || isStopped || isAborted)
285
+ return;
286
+ const wasSkipped = skippedLast;
287
+ skippedLast = false;
288
+ let decision;
289
+ try {
290
+ decision = rateController.observe({ hasPendingWork: queue.length > head, wasBackedOff: wasSkipped });
291
+ }
292
+ catch (error) {
293
+ hasStrategyFailure = true;
294
+ strategyFailure = error;
295
+ halt();
296
+ discardSettledWindow();
297
+ throw error;
298
+ }
299
+ observationWindow = undefined;
300
+ applyRate(decision.rate);
301
+ if (decision.shouldBackOff && back_off) {
302
+ skippedLast = true;
303
+ timeout = setTimeout(resumeSettledScheduling, interval);
304
+ return;
305
+ }
306
+ if (queue.length > head)
307
+ beginSettledWindow();
308
+ else
309
+ halt();
310
+ }
311
+ function closeSettledWindow() {
312
+ dynTimeout = undefined;
313
+ collectingSettledWindow = false;
314
+ clearTimeout(timeout);
315
+ timeout = undefined;
316
+ if (settledOutstanding === 0)
317
+ finishSettledWindow();
318
+ }
319
+ function resumeSettledScheduling() {
320
+ skippedLast = false;
321
+ beginSettledWindow();
322
+ }
323
+ function beginSettledWindow() {
324
+ if (isAborted || isPaused || isStopped || skippedLast || queue.length <= head)
325
+ return;
326
+ isRunning = true;
327
+ collectingSettledWindow = true;
328
+ observationWindow = nextObservationWindow++;
329
+ last_called = Date.now();
330
+ clearTimeout(timeout);
331
+ timeout = setTimeout(dequeue, dyn_interval);
332
+ clearTimeout(dynTimeout);
333
+ dynTimeout = setTimeout(closeSettledWindow, interval);
334
+ }
123
335
  function start() {
336
+ if (isAborted || isPaused || isStopped)
337
+ return;
124
338
  if (skippedLast)
125
339
  return;
340
+ if (usesSettledTiming) {
341
+ beginSettledWindow();
342
+ return;
343
+ }
126
344
  isRunning = true;
127
345
  last_called = Date.now();
128
346
  clearTimeout(timeout);
@@ -131,15 +349,48 @@ export function createScheduler(options, rateController) {
131
349
  dynTimeout = setTimeout(adjustRate, interval);
132
350
  }
133
351
  function enqueue(callback) {
352
+ if (isAborted)
353
+ throw new Error("Cannot enqueue work after the queue has been aborted");
134
354
  if (hasStrategyFailure)
135
355
  throw strategyFailure;
356
+ if (reserved_count >= max_queue_size)
357
+ throw new Error("Cannot enqueue work: maxQueueSize has been reached");
358
+ reserved_count++;
136
359
  queue.push({ fn: callback, retries: retry });
360
+ const wasStopped = isStopped;
137
361
  isStopped = false;
138
- if (!isRunning)
362
+ if (wasStopped)
363
+ resumeDelayedRetries();
364
+ if (!isRunning && !isPaused)
139
365
  start();
140
366
  }
367
+ function getLifecycleState() {
368
+ if (isAborted)
369
+ return "aborted";
370
+ if (isStopped)
371
+ return "stopped";
372
+ if (isPaused)
373
+ return "paused";
374
+ return "running";
375
+ }
376
+ enqueue.pause = pause;
377
+ enqueue.resume = resume;
141
378
  enqueue.stop = stop;
142
- Object.defineProperty(enqueue, "pending", { get: () => queue.length - head });
379
+ enqueue.abort = abort;
380
+ enqueue.waitForIdle = async () => isIdle() ? Promise.resolve() : new Promise(resolve => { idleWaiters.push(resolve); });
381
+ enqueue.getState = () => Object.freeze({
382
+ rate: current_rpi,
383
+ pending: queue.length - head + delayedRetries.length,
384
+ active: active_count,
385
+ state: getLifecycleState(),
386
+ started: cnt_started,
387
+ succeeded: cnt_succeeded,
388
+ failed: cnt_failed,
389
+ retried: cnt_retried,
390
+ rateIncreases: cnt_rateIncreases,
391
+ rateDecreases: cnt_rateDecreases,
392
+ });
393
+ Object.defineProperty(enqueue, "pending", { get: () => queue.length - head + delayedRetries.length });
143
394
  return enqueue;
144
395
  }
145
396
  //# sourceMappingURL=scheduler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,eAAe,CAAC,OAAwB,EAAE,cAA8B;IACtF,MAAM,EACJ,QAAQ,EACR,aAAa,GAAG,IAAI,EACpB,KAAK,GAAG,CAAC,EACT,WAAW,EACX,iBAAiB,GAAG,GAAG,EACvB,QAAQ,GAAG,KAAK,EAChB,YAAY,GACb,GAAG,OAAO,CAAC;IACZ,IAAI,WAAW,GAAG,cAAc,CAAC,IAAI,CAAC;IACtC,IAAI,YAAY,GAAG,aAAa,CAAC,CAAC,CAAC,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;IACrE,IAAI,yBAAyB,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;IAChE,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,OAAkD,CAAC;IACvD,IAAI,UAAqD,CAAC;IAC1D,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,IAAI,kBAAkB,GAAG,KAAK,CAAC;IAC/B,IAAI,eAAwB,CAAC;IAC7B,MAAM,eAAe,GAAG,WAAW,IAAI,QAAQ,CAAC;IAChD,MAAM,KAAK,GAAqB,EAAE,CAAC;IACnC,IAAI,IAAI,GAAG,CAAC,CAAC;IAEb,SAA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AG,cAAc,CAAC,MAAM;QACpD,MAAM,EAAE,YAAY;QACpB,KAAK,EAAE,iBAAiB,EAAE;QAC1B,OAAO,EAAE,WAAW;QACpB,SAAS,EAAE,aAAa;QACxB,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,WAAW;QACpB,aAAa,EAAE,iBAAiB;QAChC,aAAa,EAAE,iBAAiB;KACjC,CAAC,CAAC;IACH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC;IACtG,OAAO,OAAyB,CAAC;AACnC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dynamic-throttled-queue",
3
- "version": "2.2.0-rc.1849e68",
3
+ "version": "2.2.0-rc.4dd61d6",
4
4
  "type": "module",
5
5
  "description": "Dynamically throttles arbitrary code to execute between a minimum and maximum number of times per interval. Best for making throttled API requests.",
6
6
  "files": [