dynamic-throttled-queue 2.2.0-rc.1849e68 → 2.2.0-rc.9016c9c
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 +71 -2
- package/dist/dynamic-throttled-queue.d.ts +24 -1
- package/dist/dynamic-throttled-queue.js +17 -0
- package/dist/dynamic-throttled-queue.js.map +1 -1
- package/dist/rate-controller.d.ts +2 -1
- package/dist/rate-controller.js +5 -2
- package/dist/rate-controller.js.map +1 -1
- package/dist/scheduler.js +72 -23
- package/dist/scheduler.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,7 +26,16 @@ throttle(() => {
|
|
|
26
26
|
});
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
Callbacks can return `false` to signal
|
|
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.
|
|
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
|
|
|
@@ -44,6 +53,7 @@ Set `concurrency` to bound callbacks that are still awaiting asynchronous comple
|
|
|
44
53
|
| `concurrency` | `number` | — | Maximum callbacks awaiting asynchronous completion; omit for no limit |
|
|
45
54
|
| `compact_threshold` | `number` | `512` | Non-negative integer minimum dead slots before internal queue compaction triggers; `0` compacts at the earliest eligible point |
|
|
46
55
|
| `rateStrategy` | `RateStrategy` | `linear` | Pure policy that requests the next rate and an optional backoff after each observation window |
|
|
56
|
+
| `rateOutcomeClassifier` | `RateOutcomeClassifier` | — | Decides whether a failed callback outcome contributes to adaptive-rate error counting |
|
|
47
57
|
| `onRateChange` | `(rate: number) => void` | — | Called when the current rate changes |
|
|
48
58
|
|
|
49
59
|
`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`.
|
|
@@ -54,7 +64,10 @@ Set `concurrency` to bound callbacks that are still awaiting asynchronous comple
|
|
|
54
64
|
|
|
55
65
|
| Property | Type | Description |
|
|
56
66
|
| -------- | ---- | ----------- |
|
|
67
|
+
| `pause()` | `() => void` | Temporarily prevent new callback starts while retaining accepted work |
|
|
68
|
+
| `resume()` | `() => void` | Resume a paused queue with a fresh pacing and observation window |
|
|
57
69
|
| `stop()` | `() => void` | Stop processing the queue immediately |
|
|
70
|
+
| `abort()` | `() => void` | Terminally discard queued work and signal active callbacks |
|
|
58
71
|
| `pending` | `number` (readonly) | Number of callbacks still waiting in the queue |
|
|
59
72
|
|
|
60
73
|
```ts
|
|
@@ -66,8 +79,21 @@ console.log(throttle.pending); // number of queued callbacks
|
|
|
66
79
|
throttle.stop(); // halt processing
|
|
67
80
|
```
|
|
68
81
|
|
|
82
|
+
## Lifecycle
|
|
83
|
+
|
|
84
|
+
| State | Pending work and enqueue | Active work | Scheduling and lifecycle operations |
|
|
85
|
+
| ----- | ------------------------ | ----------- | ----------------------------------- |
|
|
86
|
+
| 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. |
|
|
87
|
+
| 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. `pause()` is idempotent. `stop()` clears the paused state. |
|
|
88
|
+
| Stopped | Pending work is retained. A later enqueue restarts scheduling. | Continues and settles normally. | `pause()` and `resume()` are no-ops. `stop()` is idempotent. |
|
|
89
|
+
| 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. |
|
|
90
|
+
|
|
91
|
+
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()`.
|
|
92
|
+
|
|
69
93
|
`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.
|
|
70
94
|
|
|
95
|
+
`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.
|
|
96
|
+
|
|
71
97
|
## Examples
|
|
72
98
|
|
|
73
99
|
### Basic
|
|
@@ -118,9 +144,52 @@ for (let i = 0; i < 100; i++) {
|
|
|
118
144
|
}
|
|
119
145
|
```
|
|
120
146
|
|
|
147
|
+
### Rate outcome classification
|
|
148
|
+
|
|
149
|
+
`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.
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
import {
|
|
153
|
+
createThrottledQueue,
|
|
154
|
+
type RateFailureOutcome,
|
|
155
|
+
} from "dynamic-throttled-queue";
|
|
156
|
+
|
|
157
|
+
function affectsCapacity(outcome: RateFailureOutcome) {
|
|
158
|
+
if (outcome.kind === "returned-false") return false;
|
|
159
|
+
|
|
160
|
+
// Treat HTTP 429 and 5xx as capacity signals, while ignoring other failures.
|
|
161
|
+
const status = (outcome.error as { status?: number }).status;
|
|
162
|
+
return status === 429 || (status !== undefined && status >= 500 && status < 600);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const throttle = createThrottledQueue({
|
|
166
|
+
min_rpi: 1,
|
|
167
|
+
max_rpi: 10,
|
|
168
|
+
interval: 1000,
|
|
169
|
+
rateOutcomeClassifier: affectsCapacity,
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
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.
|
|
174
|
+
|
|
121
175
|
### Rate strategies
|
|
122
176
|
|
|
123
|
-
The default `linear` strategy preserves the adaptive behavior above.
|
|
177
|
+
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.
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
import { aimd, createThrottledQueue } from "dynamic-throttled-queue";
|
|
181
|
+
|
|
182
|
+
const throttle = createThrottledQueue({
|
|
183
|
+
min_rpi: 1,
|
|
184
|
+
max_rpi: 100,
|
|
185
|
+
interval: 1000,
|
|
186
|
+
rateStrategy: aimd({ increaseBy: 2, decreaseFactor: 0.5 }),
|
|
187
|
+
});
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
`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.
|
|
191
|
+
|
|
192
|
+
You can also import and pass `linear` explicitly, or provide a custom pure strategy:
|
|
124
193
|
|
|
125
194
|
```ts
|
|
126
195
|
import {
|
|
@@ -12,9 +12,27 @@ export type RateStrategyDecision = Readonly<{
|
|
|
12
12
|
shouldBackOff: boolean;
|
|
13
13
|
}>;
|
|
14
14
|
export type RateStrategy = (observation: RateStrategyObservation) => RateStrategyDecision;
|
|
15
|
+
export type AimdOptions = {
|
|
16
|
+
increaseBy?: number;
|
|
17
|
+
decreaseFactor?: number;
|
|
18
|
+
};
|
|
19
|
+
export type RateFailureOutcome = Readonly<{
|
|
20
|
+
kind: "returned-false";
|
|
21
|
+
}> | Readonly<{
|
|
22
|
+
kind: "thrown";
|
|
23
|
+
error: unknown;
|
|
24
|
+
}> | Readonly<{
|
|
25
|
+
kind: "rejected";
|
|
26
|
+
error: unknown;
|
|
27
|
+
}>;
|
|
28
|
+
export type RateOutcomeClassifier = (outcome: RateFailureOutcome) => boolean;
|
|
15
29
|
export declare const linear: RateStrategy;
|
|
30
|
+
export declare function aimd({ increaseBy, decreaseFactor }?: AimdOptions): RateStrategy;
|
|
31
|
+
export type ExecutionContext = Readonly<{
|
|
32
|
+
signal: AbortSignal;
|
|
33
|
+
}>;
|
|
16
34
|
/** Return `false` to signal failure (increments error count, triggers retry if configured). */
|
|
17
|
-
export type ThrottleCallback = () => boolean | void | Promise<boolean | void>;
|
|
35
|
+
export type ThrottleCallback = (context: ExecutionContext) => boolean | void | Promise<boolean | void>;
|
|
18
36
|
export type ThrottleOptions = {
|
|
19
37
|
min_rpi: number;
|
|
20
38
|
interval: number;
|
|
@@ -31,11 +49,16 @@ export type ThrottleOptions = {
|
|
|
31
49
|
compact_threshold?: number;
|
|
32
50
|
/** Policy used to request the next rate and any backoff after each observation window. */
|
|
33
51
|
rateStrategy?: RateStrategy;
|
|
52
|
+
/** Decides whether a failed callback outcome contributes to adaptive-rate error counting. */
|
|
53
|
+
rateOutcomeClassifier?: RateOutcomeClassifier;
|
|
34
54
|
onRateChange?: (rate: number) => void;
|
|
35
55
|
};
|
|
36
56
|
export type ThrottleFn = (callback: ThrottleCallback) => void;
|
|
37
57
|
export type ThrottleHandle = ThrottleFn & {
|
|
58
|
+
pause: () => void;
|
|
59
|
+
resume: () => void;
|
|
38
60
|
stop: () => void;
|
|
61
|
+
abort: () => void;
|
|
39
62
|
readonly pending: number;
|
|
40
63
|
};
|
|
41
64
|
export declare function createThrottledQueue(options: ThrottleOptions): ThrottleHandle;
|
|
@@ -9,6 +9,23 @@ export const linear = ({ minRate, maxRate, currentRate, errorCount, errorThresho
|
|
|
9
9
|
}
|
|
10
10
|
return { nextRate: currentRate, shouldBackOff: false };
|
|
11
11
|
};
|
|
12
|
+
export function aimd({ increaseBy = 1, decreaseFactor = 0.5 } = {}) {
|
|
13
|
+
if (!Number.isInteger(increaseBy) || increaseBy < 1) {
|
|
14
|
+
throw new Error("increaseBy must be a positive integer");
|
|
15
|
+
}
|
|
16
|
+
if (!Number.isFinite(decreaseFactor) || decreaseFactor <= 0 || decreaseFactor >= 1) {
|
|
17
|
+
throw new Error("decreaseFactor must be a number greater than 0 and less than 1");
|
|
18
|
+
}
|
|
19
|
+
return ({ currentRate, errorCount, errorThreshold, hasPendingWork, wasBackedOff }) => {
|
|
20
|
+
if (errorCount >= errorThreshold) {
|
|
21
|
+
return { nextRate: Math.floor(currentRate * decreaseFactor), shouldBackOff: true };
|
|
22
|
+
}
|
|
23
|
+
if (!wasBackedOff && errorCount === 0 && hasPendingWork) {
|
|
24
|
+
return { nextRate: currentRate + increaseBy, shouldBackOff: false };
|
|
25
|
+
}
|
|
26
|
+
return { nextRate: currentRate, shouldBackOff: false };
|
|
27
|
+
};
|
|
28
|
+
}
|
|
12
29
|
export function createThrottledQueue(options) {
|
|
13
30
|
const { min_rpi, interval, max_rpi = min_rpi, concurrency, retry = 0, compact_threshold = 512 } = options;
|
|
14
31
|
const errors_per_interval = options.errors_per_interval ?? 5;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-throttled-queue.js","sourceRoot":"","sources":["../src/dynamic-throttled-queue.ts"],"names":[],"mappings":"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AAE,CAAC;QAClD,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,WAAW,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,WAAW,GAAG,CAAC,CAAC,EAAE,CAAC;QACrF,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,mBAAmB,CAAC,IAAI,mBAAmB,GAAG,CAAC,EAAE,CAAC;QACtE,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,iBAAiB,CAAC,IAAI,iBAAiB,GAAG,CAAC,EAAE,CAAC;QAClE,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC;IACD,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
|
-
|
|
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;
|
package/dist/rate-controller.js
CHANGED
|
@@ -18,8 +18,11 @@ export function createRateController(options, strategy) {
|
|
|
18
18
|
get rate() {
|
|
19
19
|
return rate;
|
|
20
20
|
},
|
|
21
|
-
|
|
22
|
-
|
|
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":"
|
|
1
|
+
{"version":3,"file":"rate-controller.js","sourceRoot":"","sources":["../src/rate-controller.ts"],"names":[],"mappings":"AAyBA,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,EAAE,CAAC;QAClF,MAAM,IAAI,SAAS,CAAC,qDAAqD,CAAC,CAAC;IAC7E,CAAC;IACD,IAAI,OAAO,SAAS,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QACjD,MAAM,IAAI,SAAS,CAAC,mDAAmD,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,OAA8B,EAAE,QAAsB;IACzF,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9D,IAAI,UAAU,GAAG,CAAC,CAAC;IAEnB,OAAO;QACL,IAAI,IAAI;YACN,OAAO,IAAI,CAAC;QACd,CAAC;QACD,gBAAgB;YACd,UAAU,GAAG,CAAC,CAAC;QACjB,CAAC;QACD,gBAAgB,CAAC,cAAuB;YACtC,IAAI,cAAc;gBAAE,UAAU,EAAE,CAAC;QACnC,CAAC;QACD,OAAO,CAAC,WAAwB;YAC9B,MAAM,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;gBACvD,WAAW,EAAE,IAAI;gBACjB,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,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"}
|
package/dist/scheduler.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function createScheduler(options, rateController) {
|
|
2
|
-
const { interval, evenly_spaced = true, retry = 0, concurrency, compact_threshold = 512, back_off = false, onRateChange, } = options;
|
|
2
|
+
const { interval, evenly_spaced = true, retry = 0, concurrency, compact_threshold = 512, back_off = false, rateOutcomeClassifier, onRateChange, } = options;
|
|
3
3
|
let current_rpi = rateController.rate;
|
|
4
4
|
let dyn_interval = evenly_spaced ? interval / current_rpi : interval;
|
|
5
5
|
let dyn_requests_per_interval = evenly_spaced ? 1 : current_rpi;
|
|
@@ -9,9 +9,12 @@ export function createScheduler(options, rateController) {
|
|
|
9
9
|
let timeout;
|
|
10
10
|
let dynTimeout;
|
|
11
11
|
let active_count = 0;
|
|
12
|
+
let isPaused = false;
|
|
12
13
|
let isStopped = false;
|
|
14
|
+
let isAborted = false;
|
|
13
15
|
let hasStrategyFailure = false;
|
|
14
16
|
let strategyFailure;
|
|
17
|
+
const abortController = new AbortController();
|
|
15
18
|
const max_concurrency = concurrency ?? Infinity;
|
|
16
19
|
const queue = [];
|
|
17
20
|
let head = 0;
|
|
@@ -29,22 +32,75 @@ export function createScheduler(options, rateController) {
|
|
|
29
32
|
}
|
|
30
33
|
function stop() {
|
|
31
34
|
isStopped = true;
|
|
35
|
+
isPaused = false;
|
|
32
36
|
halt();
|
|
33
37
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
function pause() {
|
|
39
|
+
if (isAborted || isStopped || isPaused)
|
|
40
|
+
return;
|
|
41
|
+
isPaused = true;
|
|
42
|
+
rateController.clearObservation();
|
|
43
|
+
halt();
|
|
44
|
+
}
|
|
45
|
+
function resume() {
|
|
46
|
+
if (!isPaused)
|
|
47
|
+
return;
|
|
48
|
+
isPaused = false;
|
|
49
|
+
if (queue.length > head)
|
|
50
|
+
start();
|
|
51
|
+
}
|
|
52
|
+
function abort() {
|
|
53
|
+
if (isAborted)
|
|
54
|
+
return;
|
|
55
|
+
isAborted = true;
|
|
56
|
+
halt();
|
|
57
|
+
queue.length = 0;
|
|
58
|
+
head = 0;
|
|
59
|
+
abortController.abort();
|
|
60
|
+
}
|
|
61
|
+
function isRateReducing(outcome) {
|
|
62
|
+
if (!outcome)
|
|
63
|
+
return false;
|
|
64
|
+
try {
|
|
65
|
+
return rateOutcomeClassifier?.(outcome) ?? true;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function handleResult(item, outcome) {
|
|
72
|
+
if (isAborted)
|
|
73
|
+
return;
|
|
74
|
+
if (!isPaused)
|
|
75
|
+
rateController.recordCompletion(isRateReducing(outcome));
|
|
76
|
+
if (outcome && item.retries > 0) {
|
|
37
77
|
queue.push({ fn: item.fn, retries: item.retries - 1 });
|
|
38
|
-
if (!isRunning && !isStopped && queue.length > head)
|
|
78
|
+
if (!isRunning && !isPaused && !isStopped && queue.length > head)
|
|
39
79
|
start();
|
|
40
80
|
}
|
|
41
81
|
}
|
|
42
|
-
function handleSettlement(item,
|
|
82
|
+
function handleSettlement(item, outcome, resume = false) {
|
|
43
83
|
active_count--;
|
|
44
|
-
handleResult(item,
|
|
84
|
+
handleResult(item, outcome);
|
|
45
85
|
if (resume && isRunning && !skippedLast && queue.length > head)
|
|
46
86
|
dequeue();
|
|
47
87
|
}
|
|
88
|
+
function execute(item) {
|
|
89
|
+
active_count++;
|
|
90
|
+
let result;
|
|
91
|
+
try {
|
|
92
|
+
result = item.fn({ signal: abortController.signal });
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
handleSettlement(item, { kind: "thrown", error });
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (result instanceof Promise) {
|
|
99
|
+
void result.then(value => handleSettlement(item, value === false ? { kind: "returned-false" } : undefined, true), (error) => handleSettlement(item, { kind: "rejected", error }, true));
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
handleSettlement(item, result === false ? { kind: "returned-false" } : undefined);
|
|
103
|
+
}
|
|
48
104
|
function dequeue() {
|
|
49
105
|
const threshold = last_called + dyn_interval;
|
|
50
106
|
const now = Date.now();
|
|
@@ -57,23 +113,9 @@ export function createScheduler(options, rateController) {
|
|
|
57
113
|
let started = 0;
|
|
58
114
|
while (head < end && active_count < max_concurrency) {
|
|
59
115
|
const item = queue[head++];
|
|
60
|
-
active_count++;
|
|
61
116
|
if (started++ === 0)
|
|
62
117
|
last_called = Date.now();
|
|
63
|
-
|
|
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
|
-
}
|
|
118
|
+
execute(item);
|
|
77
119
|
}
|
|
78
120
|
if (head > compact_threshold && head > queue.length / 2) {
|
|
79
121
|
queue.splice(0, head);
|
|
@@ -121,6 +163,8 @@ export function createScheduler(options, rateController) {
|
|
|
121
163
|
dynTimeout = setTimeout(adjustRate, interval);
|
|
122
164
|
}
|
|
123
165
|
function start() {
|
|
166
|
+
if (isAborted || isPaused || isStopped)
|
|
167
|
+
return;
|
|
124
168
|
if (skippedLast)
|
|
125
169
|
return;
|
|
126
170
|
isRunning = true;
|
|
@@ -131,14 +175,19 @@ export function createScheduler(options, rateController) {
|
|
|
131
175
|
dynTimeout = setTimeout(adjustRate, interval);
|
|
132
176
|
}
|
|
133
177
|
function enqueue(callback) {
|
|
178
|
+
if (isAborted)
|
|
179
|
+
throw new Error("Cannot enqueue work after the queue has been aborted");
|
|
134
180
|
if (hasStrategyFailure)
|
|
135
181
|
throw strategyFailure;
|
|
136
182
|
queue.push({ fn: callback, retries: retry });
|
|
137
183
|
isStopped = false;
|
|
138
|
-
if (!isRunning)
|
|
184
|
+
if (!isRunning && !isPaused)
|
|
139
185
|
start();
|
|
140
186
|
}
|
|
187
|
+
enqueue.pause = pause;
|
|
188
|
+
enqueue.resume = resume;
|
|
141
189
|
enqueue.stop = stop;
|
|
190
|
+
enqueue.abort = abort;
|
|
142
191
|
Object.defineProperty(enqueue, "pending", { get: () => queue.length - head });
|
|
143
192
|
return enqueue;
|
|
144
193
|
}
|
package/dist/scheduler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,eAAe,CAAC,OAAwB,EAAE,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": "2.2.0-rc.
|
|
3
|
+
"version": "2.2.0-rc.9016c9c",
|
|
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": [
|