@grackle-ai/adapter-sdk 0.191.0 → 0.193.0
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/dist/retry.d.ts +5 -20
- package/dist/retry.d.ts.map +1 -1
- package/dist/retry.js +1 -32
- package/dist/retry.js.map +1 -1
- package/package.json +4 -4
package/dist/retry.d.ts
CHANGED
|
@@ -1,23 +1,8 @@
|
|
|
1
|
-
/** Options for {@link retryWithBackoff}. */
|
|
2
|
-
export interface RetryOptions {
|
|
3
|
-
/** Total number of attempts (first try + retries). Must be at least 1. */
|
|
4
|
-
maxAttempts: number;
|
|
5
|
-
/** Delay before the first retry (milliseconds). */
|
|
6
|
-
delayMs: number;
|
|
7
|
-
/** Multiplier applied to the delay after each retry (default `1` = fixed delay). */
|
|
8
|
-
backoffMultiplier?: number;
|
|
9
|
-
/** Upper bound on the computed delay (milliseconds). Only meaningful when `backoffMultiplier` is greater than 1. */
|
|
10
|
-
maxDelayMs?: number;
|
|
11
|
-
/** Called after each failed attempt, before the backoff sleep. */
|
|
12
|
-
onRetry?: (attempt: number, error: unknown) => void | Promise<void>;
|
|
13
|
-
/** Override the sleep implementation (primarily for testing). */
|
|
14
|
-
sleep?: (ms: number) => Promise<void>;
|
|
15
|
-
}
|
|
16
1
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* @throws The error from the last failed attempt when all attempts are exhausted.
|
|
2
|
+
* Re-export from `@grackle-ai/common` so existing consumers keep working.
|
|
3
|
+
* The implementation lives in common so `@grackle-ai/runtime-sdk` (which only
|
|
4
|
+
* depends on common) can also use it without a circular dependency.
|
|
21
5
|
*/
|
|
22
|
-
export
|
|
6
|
+
export type { RetryOptions } from "@grackle-ai/common";
|
|
7
|
+
export { retryWithBackoff } from "@grackle-ai/common";
|
|
23
8
|
//# sourceMappingURL=retry.d.ts.map
|
package/dist/retry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/retry.js
CHANGED
|
@@ -1,33 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Execute `operation` up to {@link RetryOptions.maxAttempts} times, sleeping
|
|
4
|
-
* with optional exponential backoff between failures.
|
|
5
|
-
*
|
|
6
|
-
* @throws The error from the last failed attempt when all attempts are exhausted.
|
|
7
|
-
*/
|
|
8
|
-
export async function retryWithBackoff(operation, options) {
|
|
9
|
-
const { maxAttempts, delayMs, backoffMultiplier = 1, maxDelayMs = Infinity, onRetry, sleep = defaultSleep, } = options;
|
|
10
|
-
if (maxAttempts < 1) {
|
|
11
|
-
throw new RangeError(`retryWithBackoff: maxAttempts must be at least 1, got ${maxAttempts}`);
|
|
12
|
-
}
|
|
13
|
-
let lastError;
|
|
14
|
-
let currentDelay = Math.min(delayMs, maxDelayMs);
|
|
15
|
-
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
16
|
-
try {
|
|
17
|
-
return await operation();
|
|
18
|
-
}
|
|
19
|
-
catch (err) {
|
|
20
|
-
lastError = err;
|
|
21
|
-
if (attempt === maxAttempts) {
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
if (onRetry) {
|
|
25
|
-
await onRetry(attempt, err);
|
|
26
|
-
}
|
|
27
|
-
await sleep(currentDelay);
|
|
28
|
-
currentDelay = Math.min(currentDelay * backoffMultiplier, maxDelayMs);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
throw lastError;
|
|
32
|
-
}
|
|
1
|
+
export { retryWithBackoff } from "@grackle-ai/common";
|
|
33
2
|
//# sourceMappingURL=retry.js.map
|
package/dist/retry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grackle-ai/adapter-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.193.0",
|
|
4
4
|
"description": "SDK for building Grackle environment adapters",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"dist/"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@grackle-ai/ahp
|
|
32
|
-
"@grackle-ai/
|
|
33
|
-
"@grackle-ai/
|
|
31
|
+
"@grackle-ai/ahp": "0.193.0",
|
|
32
|
+
"@grackle-ai/ahp-transport": "0.193.0",
|
|
33
|
+
"@grackle-ai/common": "0.193.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@rushstack/heft": "1.2.7",
|