@databricks/sdk-core 0.33.0 → 0.35.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/apierror/apierror.d.ts +52 -49
- package/dist/apierror/apierror.d.ts.map +1 -1
- package/dist/apierror/apierror.js +124 -172
- package/dist/apierror/apierror.js.map +1 -1
- package/dist/apierror/codes/codes.d.ts +113 -113
- package/dist/apierror/codes/codes.d.ts.map +1 -1
- package/dist/apierror/codes/codes.js +24 -115
- package/dist/apierror/codes/codes.js.map +1 -1
- package/dist/apierror/codes/index.d.ts +2 -7
- package/dist/apierror/codes/index.js +3 -7
- package/dist/apierror/details.d.ts +104 -101
- package/dist/apierror/details.d.ts.map +1 -1
- package/dist/apierror/details.js +151 -226
- package/dist/apierror/details.js.map +1 -1
- package/dist/apierror/index.d.ts +3 -8
- package/dist/apierror/index.js +3 -7
- package/dist/clientinfo/agent.d.ts +6 -3
- package/dist/clientinfo/agent.d.ts.map +1 -1
- package/dist/clientinfo/agent.js +134 -112
- package/dist/clientinfo/agent.js.map +1 -1
- package/dist/clientinfo/base.d.ts +13 -15
- package/dist/clientinfo/base.d.ts.map +1 -1
- package/dist/clientinfo/base.js +50 -50
- package/dist/clientinfo/base.js.map +1 -1
- package/dist/clientinfo/clientinfo.d.ts +40 -38
- package/dist/clientinfo/clientinfo.d.ts.map +1 -1
- package/dist/clientinfo/clientinfo.js +78 -88
- package/dist/clientinfo/clientinfo.js.map +1 -1
- package/dist/clientinfo/default.browser.d.ts +6 -10
- package/dist/clientinfo/default.browser.d.ts.map +1 -1
- package/dist/clientinfo/default.browser.js +24 -16
- package/dist/clientinfo/default.browser.js.map +1 -1
- package/dist/clientinfo/default.d.ts +8 -4
- package/dist/clientinfo/default.d.ts.map +1 -1
- package/dist/clientinfo/default.js +157 -102
- package/dist/clientinfo/default.js.map +1 -1
- package/dist/clientinfo/index.browser.d.ts +4 -5
- package/dist/clientinfo/index.browser.js +5 -4
- package/dist/clientinfo/index.d.ts +4 -5
- package/dist/clientinfo/index.js +5 -4
- package/dist/clientinfo/meta-harness.d.ts +6 -3
- package/dist/clientinfo/meta-harness.d.ts.map +1 -1
- package/dist/clientinfo/meta-harness.js +30 -46
- package/dist/clientinfo/meta-harness.js.map +1 -1
- package/dist/http/http.d.ts +25 -22
- package/dist/http/http.d.ts.map +1 -1
- package/dist/http/http.js +24 -34
- package/dist/http/http.js.map +1 -1
- package/dist/http/index.d.ts +2 -8
- package/dist/http/index.js +3 -7
- package/dist/index.d.ts +1 -6
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/logger/index.d.ts +2 -8
- package/dist/logger/index.js +3 -7
- package/dist/logger/logger.d.ts +26 -23
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.js +46 -60
- package/dist/logger/logger.js.map +1 -1
- package/dist/ops/execute.d.ts +7 -3
- package/dist/ops/execute.d.ts.map +1 -1
- package/dist/ops/execute.js +55 -67
- package/dist/ops/execute.js.map +1 -1
- package/dist/ops/index.d.ts +5 -12
- package/dist/ops/index.js +4 -9
- package/dist/ops/limiter.d.ts +5 -2
- package/dist/ops/limiter.d.ts.map +1 -1
- package/dist/ops/limiter.js +0 -2
- package/dist/ops/options.d.ts +23 -19
- package/dist/ops/options.d.ts.map +1 -1
- package/dist/ops/options.js +0 -2
- package/dist/ops/retrier.d.ts +34 -31
- package/dist/ops/retrier.d.ts.map +1 -1
- package/dist/ops/retrier.js +55 -66
- package/dist/ops/retrier.js.map +1 -1
- package/dist/package.js +6 -0
- package/dist/package.js.map +1 -0
- package/dist/profiles/errors.d.ts +7 -4
- package/dist/profiles/errors.d.ts.map +1 -1
- package/dist/profiles/errors.js +16 -17
- package/dist/profiles/errors.js.map +1 -1
- package/dist/profiles/index.browser.d.ts +4 -10
- package/dist/profiles/index.browser.js +4 -8
- package/dist/profiles/index.d.ts +5 -15
- package/dist/profiles/index.js +5 -13
- package/dist/profiles/ini.d.ts +6 -3
- package/dist/profiles/ini.d.ts.map +1 -1
- package/dist/profiles/ini.js +60 -108
- package/dist/profiles/ini.js.map +1 -1
- package/dist/profiles/profile.d.ts +66 -67
- package/dist/profiles/profile.d.ts.map +1 -1
- package/dist/profiles/profile.js +89 -84
- package/dist/profiles/profile.js.map +1 -1
- package/dist/profiles/resolve.d.ts +8 -9
- package/dist/profiles/resolve.d.ts.map +1 -1
- package/dist/profiles/resolve.js +140 -185
- package/dist/profiles/resolve.js.map +1 -1
- package/dist/profiles/secret.d.ts +15 -12
- package/dist/profiles/secret.d.ts.map +1 -1
- package/dist/profiles/secret.js +38 -35
- package/dist/profiles/secret.js.map +1 -1
- package/dist/wkt/fieldmask.d.ts +23 -20
- package/dist/wkt/fieldmask.d.ts.map +1 -1
- package/dist/wkt/fieldmask.js +53 -62
- package/dist/wkt/fieldmask.js.map +1 -1
- package/dist/wkt/index.d.ts +3 -4
- package/dist/wkt/index.js +3 -2
- package/dist/wkt/value.d.ts +6 -3
- package/dist/wkt/value.d.ts.map +1 -1
- package/dist/wkt/value.js +0 -2
- package/package.json +2 -2
- package/dist/apierror/codes/index.d.ts.map +0 -1
- package/dist/apierror/codes/index.js.map +0 -1
- package/dist/apierror/index.d.ts.map +0 -1
- package/dist/apierror/index.js.map +0 -1
- package/dist/clientinfo/index.browser.d.ts.map +0 -1
- package/dist/clientinfo/index.browser.js.map +0 -1
- package/dist/clientinfo/index.d.ts.map +0 -1
- package/dist/clientinfo/index.js.map +0 -1
- package/dist/http/index.d.ts.map +0 -1
- package/dist/http/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/logger/index.d.ts.map +0 -1
- package/dist/logger/index.js.map +0 -1
- package/dist/ops/index.d.ts.map +0 -1
- package/dist/ops/index.js.map +0 -1
- package/dist/ops/limiter.js.map +0 -1
- package/dist/ops/options.js.map +0 -1
- package/dist/profiles/index.browser.d.ts.map +0 -1
- package/dist/profiles/index.browser.js.map +0 -1
- package/dist/profiles/index.d.ts.map +0 -1
- package/dist/profiles/index.js.map +0 -1
- package/dist/wkt/index.d.ts.map +0 -1
- package/dist/wkt/index.js.map +0 -1
- package/dist/wkt/value.js.map +0 -1
package/dist/ops/execute.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Options } from "./options.js";
|
|
2
|
+
|
|
3
|
+
//#region src/ops/execute.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Sleeps for the given duration. It is mostly equivalent to setTimeout, but
|
|
4
6
|
* can be interrupted by the AbortSignal if the signal aborts before the
|
|
5
7
|
* duration elapses.
|
|
6
8
|
*/
|
|
7
|
-
|
|
9
|
+
declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
8
10
|
/** Executes operation op with the given options. */
|
|
9
|
-
|
|
11
|
+
declare function execute(signal: AbortSignal | undefined, op: (signal?: AbortSignal) => Promise<void>, options?: Options): Promise<void>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { execute, sleep };
|
|
10
14
|
//# sourceMappingURL=execute.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","
|
|
1
|
+
{"version":3,"file":"execute.d.ts","names":[],"sources":["../../src/ops/execute.ts"],"mappings":";;;;;AAaA;;;iBAAgB,KAAA,CAAM,EAAA,UAAY,MAAA,GAAS,WAAA,GAAc,OAAA;;iBA0BnC,OAAA,CACpB,MAAA,EAAQ,WAAA,cACR,EAAA,GAAK,MAAA,GAAS,WAAA,KAAgB,OAAA,QAC9B,OAAA,GAAU,OAAA,GACT,OAAA"}
|
package/dist/ops/execute.js
CHANGED
|
@@ -1,77 +1,65 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/ops/execute.ts
|
|
2
2
|
function toError(value) {
|
|
3
|
-
|
|
3
|
+
return value instanceof Error ? value : new Error(String(value));
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
6
|
+
* Sleeps for the given duration. It is mostly equivalent to setTimeout, but
|
|
7
|
+
* can be interrupted by the AbortSignal if the signal aborts before the
|
|
8
|
+
* duration elapses.
|
|
9
|
+
*/
|
|
10
|
+
function sleep(ms, signal) {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
if (signal?.aborted === true) {
|
|
13
|
+
reject(toError(signal.reason));
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (signal === void 0) {
|
|
17
|
+
setTimeout(resolve, ms);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const onAbort = () => {
|
|
21
|
+
clearTimeout(timer);
|
|
22
|
+
reject(toError(signal.reason));
|
|
23
|
+
};
|
|
24
|
+
const timer = setTimeout(() => {
|
|
25
|
+
signal.removeEventListener("abort", onAbort);
|
|
26
|
+
resolve();
|
|
27
|
+
}, ms);
|
|
28
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
29
|
+
});
|
|
30
30
|
}
|
|
31
31
|
/** Executes operation op with the given options. */
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return executeImpl(signal, op, opts, sleep);
|
|
32
|
+
async function execute(signal, op, options) {
|
|
33
|
+
return executeImpl(signal, op, { ...options }, sleep);
|
|
35
34
|
}
|
|
36
35
|
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
* The actual implementation of execute. Its purpose is to ease testing by
|
|
37
|
+
* providing a convenient way to mock the sleeping logic.
|
|
38
|
+
*/
|
|
40
39
|
async function executeImpl(signal, op, opts, sleep) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (opts.retrier) {
|
|
63
|
-
retrier = opts.retrier(); // Lazily instantiate the retrier.
|
|
64
|
-
}
|
|
65
|
-
if (retrier === undefined) {
|
|
66
|
-
throw error; // No retrier == no retry.
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
const delay = retrier.isRetriable(error);
|
|
70
|
-
if (delay === undefined) {
|
|
71
|
-
throw error; // Not retriable.
|
|
72
|
-
}
|
|
73
|
-
await sleep(delay, signal);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
40
|
+
if (opts.timeout !== void 0 && opts.timeout > 0) {
|
|
41
|
+
const timeoutSignal = AbortSignal.timeout(opts.timeout);
|
|
42
|
+
signal = signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal;
|
|
43
|
+
}
|
|
44
|
+
let retrier;
|
|
45
|
+
for (;;) {
|
|
46
|
+
if (opts.rateLimiter) await opts.rateLimiter.wait(signal);
|
|
47
|
+
try {
|
|
48
|
+
await op(signal);
|
|
49
|
+
return;
|
|
50
|
+
} catch (err) {
|
|
51
|
+
const error = toError(err);
|
|
52
|
+
if (retrier === void 0) {
|
|
53
|
+
if (opts.retrier) retrier = opts.retrier();
|
|
54
|
+
if (retrier === void 0) throw error;
|
|
55
|
+
}
|
|
56
|
+
const delay = retrier.isRetriable(error);
|
|
57
|
+
if (delay === void 0) throw error;
|
|
58
|
+
await sleep(delay, signal);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
76
61
|
}
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
export { execute, sleep };
|
|
77
65
|
//# sourceMappingURL=execute.js.map
|
package/dist/ops/execute.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.js","
|
|
1
|
+
{"version":3,"file":"execute.js","names":[],"sources":["../../src/ops/execute.ts"],"sourcesContent":["import type {Options} from './options';\nimport type {Retrier} from './retrier';\n\n// Coerces an unknown value to an Error instance.\nfunction toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value));\n}\n\n/**\n * Sleeps for the given duration. It is mostly equivalent to setTimeout, but\n * can be interrupted by the AbortSignal if the signal aborts before the\n * duration elapses.\n */\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (signal?.aborted === true) {\n reject(toError(signal.reason));\n return;\n }\n if (signal === undefined) {\n setTimeout(resolve, ms);\n return;\n }\n const onAbort = (): void => {\n clearTimeout(timer);\n reject(toError(signal.reason));\n };\n const timer = setTimeout(() => {\n signal.removeEventListener('abort', onAbort);\n resolve();\n }, ms);\n signal.addEventListener('abort', onAbort, {once: true});\n });\n}\n\n// Sleeper is a convenience type for readability.\ntype Sleeper = (ms: number, signal?: AbortSignal) => Promise<void>;\n\n/** Executes operation op with the given options. */\nexport async function execute(\n signal: AbortSignal | undefined,\n op: (signal?: AbortSignal) => Promise<void>,\n options?: Options\n): Promise<void> {\n const opts: Options = {...options};\n return executeImpl(signal, op, opts, sleep);\n}\n\n/**\n * The actual implementation of execute. Its purpose is to ease testing by\n * providing a convenient way to mock the sleeping logic.\n */\nasync function executeImpl(\n signal: AbortSignal | undefined,\n op: (signal?: AbortSignal) => Promise<void>,\n opts: Options,\n sleep: Sleeper\n): Promise<void> {\n // Optionally combine the signal with a timeout signal. If the signal\n // already has a deadline, that deadline is updated to the minimum of the\n // signal's deadline and the timeout.\n if (opts.timeout !== undefined && opts.timeout > 0) {\n const timeoutSignal = AbortSignal.timeout(opts.timeout);\n signal = signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal;\n }\n\n // Get a new retrier for this specific execution. This is instantiated\n // lazily if and when the first operation execution returns an error.\n let retrier: Retrier | undefined;\n\n for (;;) {\n if (opts.rateLimiter) {\n await opts.rateLimiter.wait(signal);\n }\n\n try {\n await op(signal);\n return; // Nothing to retry.\n } catch (err: unknown) {\n const error = toError(err);\n\n if (retrier === undefined) {\n if (opts.retrier) {\n retrier = opts.retrier(); // Lazily instantiate the retrier.\n }\n if (retrier === undefined) {\n throw error; // No retrier == no retry.\n }\n }\n\n const delay = retrier.isRetriable(error);\n if (delay === undefined) {\n throw error; // Not retriable.\n }\n\n await sleep(delay, signal);\n }\n }\n}\n"],"mappings":";AAIA,SAAS,QAAQ,OAAuB;AACtC,QAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,CAAC;;;;;;;AAQlE,SAAgB,MAAM,IAAY,QAAqC;AACrE,QAAO,IAAI,SAAe,SAAS,WAAW;AAC5C,MAAI,QAAQ,YAAY,MAAM;AAC5B,UAAO,QAAQ,OAAO,OAAO,CAAC;AAC9B;;AAEF,MAAI,WAAW,QAAW;AACxB,cAAW,SAAS,GAAG;AACvB;;EAEF,MAAM,gBAAsB;AAC1B,gBAAa,MAAM;AACnB,UAAO,QAAQ,OAAO,OAAO,CAAC;;EAEhC,MAAM,QAAQ,iBAAiB;AAC7B,UAAO,oBAAoB,SAAS,QAAQ;AAC5C,YAAS;KACR,GAAG;AACN,SAAO,iBAAiB,SAAS,SAAS,EAAC,MAAM,MAAK,CAAC;GACvD;;;AAOJ,eAAsB,QACpB,QACA,IACA,SACe;AAEf,QAAO,YAAY,QAAQ,IADL,EAAC,GAAG,SAAQ,EACG,MAAM;;;;;;AAO7C,eAAe,YACb,QACA,IACA,MACA,OACe;AAIf,KAAI,KAAK,YAAY,UAAa,KAAK,UAAU,GAAG;EAClD,MAAM,gBAAgB,YAAY,QAAQ,KAAK,QAAQ;AACvD,WAAS,SAAS,YAAY,IAAI,CAAC,QAAQ,cAAc,CAAC,GAAG;;CAK/D,IAAI;AAEJ,UAAS;AACP,MAAI,KAAK,YACP,OAAM,KAAK,YAAY,KAAK,OAAO;AAGrC,MAAI;AACF,SAAM,GAAG,OAAO;AAChB;WACO,KAAc;GACrB,MAAM,QAAQ,QAAQ,IAAI;AAE1B,OAAI,YAAY,QAAW;AACzB,QAAI,KAAK,QACP,WAAU,KAAK,SAAS;AAE1B,QAAI,YAAY,OACd,OAAM;;GAIV,MAAM,QAAQ,QAAQ,YAAY,MAAM;AACxC,OAAI,UAAU,OACZ,OAAM;AAGR,SAAM,MAAM,OAAO,OAAO"}
|
package/dist/ops/index.d.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
export { execute } from './execute';
|
|
8
|
-
export type { Limiter } from './limiter';
|
|
9
|
-
export type { Options } from './options';
|
|
10
|
-
export { BackoffPolicy, retryOn } from './retrier';
|
|
11
|
-
export type { BackoffPolicyOptions, Retrier } from './retrier';
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
import { Limiter } from "./limiter.js";
|
|
2
|
+
import { BackoffPolicy, BackoffPolicyOptions, Retrier, retryOn } from "./retrier.js";
|
|
3
|
+
import { Options } from "./options.js";
|
|
4
|
+
import { execute } from "./execute.js";
|
|
5
|
+
export { BackoffPolicy, type BackoffPolicyOptions, type Limiter, type Options, type Retrier, execute, retryOn };
|
package/dist/ops/index.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* @packageDocumentation
|
|
6
|
-
*/
|
|
7
|
-
export { execute } from './execute';
|
|
8
|
-
export { BackoffPolicy, retryOn } from './retrier';
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { execute } from "./execute.js";
|
|
2
|
+
import { BackoffPolicy, retryOn } from "./retrier.js";
|
|
3
|
+
|
|
4
|
+
export { BackoffPolicy, execute, retryOn };
|
package/dist/ops/limiter.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
//#region src/ops/limiter.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Limiter is anything that can wait. It is typically used to implement
|
|
3
4
|
* client-side rate limiting. Implementations of this interface must be
|
|
4
5
|
* safe to call concurrently.
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
interface Limiter {
|
|
8
|
+
wait(signal?: AbortSignal): Promise<void>;
|
|
8
9
|
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { Limiter };
|
|
9
12
|
//# sourceMappingURL=limiter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limiter.d.ts","
|
|
1
|
+
{"version":3,"file":"limiter.d.ts","names":[],"sources":["../../src/ops/limiter.ts"],"mappings":";;AAKA;;;;UAAiB,OAAA;EACf,IAAA,CAAK,MAAA,GAAS,WAAA,GAAc,OAAA;AAAA"}
|
package/dist/ops/limiter.js
CHANGED
package/dist/ops/options.d.ts
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { Limiter } from "./limiter.js";
|
|
2
|
+
import { Retrier } from "./retrier.js";
|
|
3
|
+
|
|
4
|
+
//#region src/ops/options.d.ts
|
|
3
5
|
/** Options that control the behavior of an operation. */
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
6
|
+
interface Options {
|
|
7
|
+
/**
|
|
8
|
+
* Provides a new Retrier to be used to execute an operation. The function
|
|
9
|
+
* is called for each operation and must be safe to call concurrently. The
|
|
10
|
+
* retrier must be fresh within the context of an execute call (e.g. no
|
|
11
|
+
* need to reset a BackoffPolicy).
|
|
12
|
+
*/
|
|
13
|
+
retrier?: (() => Retrier) | undefined;
|
|
14
|
+
/** The rate limiter used to potentially rate limit the operation. */
|
|
15
|
+
rateLimiter?: Limiter | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Timeout duration in milliseconds. If the signal already has a deadline,
|
|
18
|
+
* that deadline is updated to the minimum of the signal's deadline and the
|
|
19
|
+
* timeout. The timeout covers the whole operation execution; it is not a
|
|
20
|
+
* timeout for each intermediary call.
|
|
21
|
+
*/
|
|
22
|
+
timeout?: number | undefined;
|
|
21
23
|
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { Options };
|
|
22
26
|
//# sourceMappingURL=options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","
|
|
1
|
+
{"version":3,"file":"options.d.ts","names":[],"sources":["../../src/ops/options.ts"],"mappings":";;;;;UAIiB,OAAA;EAAA;;;;;;EAOf,OAAA,UAAiB,OAAA;EAEH;EAAd,WAAA,GAAc,OAAA;EAOP;;;;;;EAAP,OAAA;AAAA"}
|
package/dist/ops/options.js
CHANGED
package/dist/ops/retrier.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
//#region src/ops/retrier.d.ts
|
|
1
2
|
/** Options for configuring a {@link BackoffPolicy}. */
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
interface BackoffPolicyOptions {
|
|
4
|
+
/** Initial delay in milliseconds; defaults to 1000. */
|
|
5
|
+
initial?: number;
|
|
6
|
+
/** Maximum delay in milliseconds; defaults to 60000. */
|
|
7
|
+
maximum?: number;
|
|
8
|
+
/**
|
|
9
|
+
* Factor by which the delay is multiplied after each retry. The value must
|
|
10
|
+
* be greater or equal to 1. If not, it defaults to 2.
|
|
11
|
+
*/
|
|
12
|
+
factor?: number;
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
declare const rand: {
|
|
15
|
+
int(n: number): number;
|
|
15
16
|
};
|
|
16
17
|
/**
|
|
17
18
|
* BackoffPolicy implements an exponential backoff policy. The delay between
|
|
@@ -25,26 +26,26 @@ export declare const rand: {
|
|
|
25
26
|
*
|
|
26
27
|
* [Exponential Backoff And Jitter]: https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
|
|
27
28
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
declare class BackoffPolicy {
|
|
30
|
+
/** Initial delay in milliseconds. */
|
|
31
|
+
readonly initial: number;
|
|
32
|
+
/** Maximum delay in milliseconds. */
|
|
33
|
+
readonly maximum: number;
|
|
34
|
+
/** Factor by which the delay is multiplied after each retry. */
|
|
35
|
+
readonly factor: number;
|
|
36
|
+
private current;
|
|
37
|
+
constructor(options?: BackoffPolicyOptions);
|
|
38
|
+
/** Returns a random delay in [0, current] and grows the current delay. */
|
|
39
|
+
delay(): number;
|
|
39
40
|
}
|
|
40
41
|
/** Retrier defines a retry behavior. */
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
interface Retrier {
|
|
43
|
+
/**
|
|
44
|
+
* Returns the delay in milliseconds before the next retry, or undefined if
|
|
45
|
+
* the error is not retriable. Implementations should assume that the given
|
|
46
|
+
* error is never undefined.
|
|
47
|
+
*/
|
|
48
|
+
isRetriable(err: Error): number | undefined;
|
|
48
49
|
}
|
|
49
50
|
/**
|
|
50
51
|
* Returns a Retrier that retries based on the isRetriable predicate and relies
|
|
@@ -54,5 +55,7 @@ export interface Retrier {
|
|
|
54
55
|
* reset by design. Users who need to reset the backoff policy should rather
|
|
55
56
|
* create a new retrier.
|
|
56
57
|
*/
|
|
57
|
-
|
|
58
|
+
declare function retryOn(options: BackoffPolicyOptions, isRetriable: (err: Error) => boolean): Retrier;
|
|
59
|
+
//#endregion
|
|
60
|
+
export { BackoffPolicy, BackoffPolicyOptions, Retrier, rand, retryOn };
|
|
58
61
|
//# sourceMappingURL=retrier.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retrier.d.ts","
|
|
1
|
+
{"version":3,"file":"retrier.d.ts","names":[],"sources":["../../src/ops/retrier.ts"],"mappings":";;UACiB,oBAAA;EAAoB;EAEnC,OAAA;EAFmC;EAKnC,OAAA;EAAA;;;;EAMA,MAAA;AAAA;AAAA,cAIW,IAAA;EAKZ,GAAA,CAAA,CAAA;AAAA;AAcD;;;;;;;;;;;;AAAA,cAAa,aAAA;EA8BN;EAAA,SA5BI,OAAA;EAwCa;EAAA,SArCb,OAAA;EA2Ca;EAAA,SAxCb,MAAA;EAAA,QAGD,OAAA;cAEI,OAAA,GAAU,oBAAA;EAmCA;EAlBtB,KAAA,CAAA;AAAA;;UAYe,OAAA;EAkBN;;;;;EAZT,WAAA,CAAY,GAAA,EAAK,KAAA;AAAA;;;;;;;;;iBAWH,OAAA,CACd,OAAA,EAAS,oBAAA,EACT,WAAA,GAAc,GAAA,EAAK,KAAA,eAClB,OAAA"}
|
package/dist/ops/retrier.js
CHANGED
|
@@ -1,70 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return Math.floor(Math.random() * n);
|
|
6
|
-
},
|
|
7
|
-
};
|
|
1
|
+
//#region src/ops/retrier.ts
|
|
2
|
+
const rand = { int(n) {
|
|
3
|
+
return Math.floor(Math.random() * n);
|
|
4
|
+
} };
|
|
8
5
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// Random duration in the range [0, this.current].
|
|
45
|
-
const d = rand.int(this.current + 1);
|
|
46
|
-
// Grow delay for the next call.
|
|
47
|
-
this.current = Math.min(this.current * this.factor, this.maximum);
|
|
48
|
-
return d;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
6
|
+
* BackoffPolicy implements an exponential backoff policy. The delay between
|
|
7
|
+
* retries is randomly computed between 0 and the "exponential delay" as
|
|
8
|
+
* recommended in [Exponential Backoff And Jitter]. The retry delay starts from
|
|
9
|
+
* initial and grows exponentially by factor at every retry. The maximum retry
|
|
10
|
+
* delay is capped by maximum.
|
|
11
|
+
*
|
|
12
|
+
* There is no parameter to limit the number of retries. This is intended as
|
|
13
|
+
* such logic should be implemented upstream (e.g. in a Retrier).
|
|
14
|
+
*
|
|
15
|
+
* [Exponential Backoff And Jitter]: https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
|
|
16
|
+
*/
|
|
17
|
+
var BackoffPolicy = class {
|
|
18
|
+
/** Initial delay in milliseconds. */
|
|
19
|
+
initial;
|
|
20
|
+
/** Maximum delay in milliseconds. */
|
|
21
|
+
maximum;
|
|
22
|
+
/** Factor by which the delay is multiplied after each retry. */
|
|
23
|
+
factor;
|
|
24
|
+
current;
|
|
25
|
+
constructor(options) {
|
|
26
|
+
let initial = options?.initial ?? 1e3;
|
|
27
|
+
const maximum = options?.maximum ?? 6e4;
|
|
28
|
+
if (initial > maximum) initial = maximum;
|
|
29
|
+
this.initial = initial;
|
|
30
|
+
this.maximum = maximum;
|
|
31
|
+
this.factor = options?.factor !== void 0 && options.factor >= 1 ? options.factor : 2;
|
|
32
|
+
this.current = this.initial;
|
|
33
|
+
}
|
|
34
|
+
/** Returns a random delay in [0, current] and grows the current delay. */
|
|
35
|
+
delay() {
|
|
36
|
+
const d = rand.int(this.current + 1);
|
|
37
|
+
this.current = Math.min(this.current * this.factor, this.maximum);
|
|
38
|
+
return d;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
51
41
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
return bp.delay();
|
|
67
|
-
},
|
|
68
|
-
};
|
|
42
|
+
* Returns a Retrier that retries based on the isRetriable predicate and relies
|
|
43
|
+
* on an internal backoff policy to decide how long to wait between retries.
|
|
44
|
+
*
|
|
45
|
+
* Important: the retrier has its own backoff policy which cannot be trivially
|
|
46
|
+
* reset by design. Users who need to reset the backoff policy should rather
|
|
47
|
+
* create a new retrier.
|
|
48
|
+
*/
|
|
49
|
+
function retryOn(options, isRetriable) {
|
|
50
|
+
const bp = new BackoffPolicy(options);
|
|
51
|
+
return { isRetriable(err) {
|
|
52
|
+
if (!isRetriable(err)) return;
|
|
53
|
+
return bp.delay();
|
|
54
|
+
} };
|
|
69
55
|
}
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
export { BackoffPolicy, rand, retryOn };
|
|
70
59
|
//# sourceMappingURL=retrier.js.map
|
package/dist/ops/retrier.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retrier.js","
|
|
1
|
+
{"version":3,"file":"retrier.js","names":[],"sources":["../../src/ops/retrier.ts"],"sourcesContent":["/** Options for configuring a {@link BackoffPolicy}. */\nexport interface BackoffPolicyOptions {\n /** Initial delay in milliseconds; defaults to 1000. */\n initial?: number;\n\n /** Maximum delay in milliseconds; defaults to 60000. */\n maximum?: number;\n\n /**\n * Factor by which the delay is multiplied after each retry. The value must\n * be greater or equal to 1. If not, it defaults to 2.\n */\n factor?: number;\n}\n\n// Random number generation, wrapped in an object for testability.\nexport const rand = {\n // Returns a random integer in [0, n).\n int(n: number): number {\n return Math.floor(Math.random() * n);\n },\n};\n\n/**\n * BackoffPolicy implements an exponential backoff policy. The delay between\n * retries is randomly computed between 0 and the \"exponential delay\" as\n * recommended in [Exponential Backoff And Jitter]. The retry delay starts from\n * initial and grows exponentially by factor at every retry. The maximum retry\n * delay is capped by maximum.\n *\n * There is no parameter to limit the number of retries. This is intended as\n * such logic should be implemented upstream (e.g. in a Retrier).\n *\n * [Exponential Backoff And Jitter]: https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/\n */\nexport class BackoffPolicy {\n /** Initial delay in milliseconds. */\n readonly initial: number;\n\n /** Maximum delay in milliseconds. */\n readonly maximum: number;\n\n /** Factor by which the delay is multiplied after each retry. */\n readonly factor: number;\n\n // Current delay before the next retry.\n private current: number;\n\n constructor(options?: BackoffPolicyOptions) {\n let initial = options?.initial ?? 1000; // Default initial delay of 1 second.\n const maximum = options?.maximum ?? 60000; // Default maximum delay of 60 seconds.\n\n if (initial > maximum) {\n // Initial cannot be greater than maximum.\n initial = maximum;\n }\n\n this.initial = initial;\n this.maximum = maximum;\n this.factor =\n options?.factor !== undefined && options.factor >= 1 ? options.factor : 2;\n this.current = this.initial;\n }\n\n /** Returns a random delay in [0, current] and grows the current delay. */\n delay(): number {\n // Random duration in the range [0, this.current].\n const d = rand.int(this.current + 1);\n\n // Grow delay for the next call.\n this.current = Math.min(this.current * this.factor, this.maximum);\n\n return d;\n }\n}\n\n/** Retrier defines a retry behavior. */\nexport interface Retrier {\n /**\n * Returns the delay in milliseconds before the next retry, or undefined if\n * the error is not retriable. Implementations should assume that the given\n * error is never undefined.\n */\n isRetriable(err: Error): number | undefined;\n}\n\n/**\n * Returns a Retrier that retries based on the isRetriable predicate and relies\n * on an internal backoff policy to decide how long to wait between retries.\n *\n * Important: the retrier has its own backoff policy which cannot be trivially\n * reset by design. Users who need to reset the backoff policy should rather\n * create a new retrier.\n */\nexport function retryOn(\n options: BackoffPolicyOptions,\n isRetriable: (err: Error) => boolean\n): Retrier {\n const bp = new BackoffPolicy(options);\n return {\n isRetriable(err: Error): number | undefined {\n if (!isRetriable(err)) {\n return undefined;\n }\n return bp.delay();\n },\n };\n}\n"],"mappings":";AAgBA,MAAa,OAAO,EAElB,IAAI,GAAmB;AACrB,QAAO,KAAK,MAAM,KAAK,QAAQ,GAAG,EAAE;GAEvC;;;;;;;;;;;;;AAcD,IAAa,gBAAb,MAA2B;;CAEzB,AAAS;;CAGT,AAAS;;CAGT,AAAS;CAGT,AAAQ;CAER,YAAY,SAAgC;EAC1C,IAAI,UAAU,SAAS,WAAW;EAClC,MAAM,UAAU,SAAS,WAAW;AAEpC,MAAI,UAAU,QAEZ,WAAU;AAGZ,OAAK,UAAU;AACf,OAAK,UAAU;AACf,OAAK,SACH,SAAS,WAAW,UAAa,QAAQ,UAAU,IAAI,QAAQ,SAAS;AAC1E,OAAK,UAAU,KAAK;;;CAItB,QAAgB;EAEd,MAAM,IAAI,KAAK,IAAI,KAAK,UAAU,EAAE;AAGpC,OAAK,UAAU,KAAK,IAAI,KAAK,UAAU,KAAK,QAAQ,KAAK,QAAQ;AAEjE,SAAO;;;;;;;;;;;AAsBX,SAAgB,QACd,SACA,aACS;CACT,MAAM,KAAK,IAAI,cAAc,QAAQ;AACrC,QAAO,EACL,YAAY,KAAgC;AAC1C,MAAI,CAAC,YAAY,IAAI,CACnB;AAEF,SAAO,GAAG,OAAO;IAEpB"}
|
package/dist/package.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
+
//#region src/profiles/errors.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Error types for Databricks configuration profile operations.
|
|
3
4
|
*
|
|
4
5
|
* @module
|
|
5
6
|
*/
|
|
6
7
|
/** Discriminant codes for {@link ProfileError}. */
|
|
7
|
-
|
|
8
|
+
type ProfileErrorCode = 'CONFIG_FILE_NOT_FOUND' | 'PROFILE_NOT_FOUND' | 'EMPTY_PATH' | 'EMPTY_PROFILE' | 'INVALID_PROFILE_NAME' | 'CONFLICTING_OPTIONS';
|
|
8
9
|
/**
|
|
9
10
|
* Error thrown by profile operations.
|
|
10
11
|
*
|
|
11
12
|
* Use the {@link ProfileError.code} field to distinguish between error causes.
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
declare class ProfileError extends Error {
|
|
15
|
+
readonly code: ProfileErrorCode;
|
|
16
|
+
constructor(code: ProfileErrorCode, message: string);
|
|
16
17
|
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { ProfileError, ProfileErrorCode };
|
|
17
20
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","
|
|
1
|
+
{"version":3,"file":"errors.d.ts","names":[],"sources":["../../src/profiles/errors.ts"],"mappings":";;AAOA;;;;;KAAY,gBAAA;;;;;;cAaC,YAAA,SAAqB,KAAA;EAAA,SACvB,IAAA,EAAM,gBAAA;cAEH,IAAA,EAAM,gBAAA,EAAkB,OAAA;AAAA"}
|
package/dist/profiles/errors.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
+
//#region src/profiles/errors.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
}
|
|
3
|
+
* Error thrown by profile operations.
|
|
4
|
+
*
|
|
5
|
+
* Use the {@link ProfileError.code} field to distinguish between error causes.
|
|
6
|
+
*/
|
|
7
|
+
var ProfileError = class extends Error {
|
|
8
|
+
code;
|
|
9
|
+
constructor(code, message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "ProfileError";
|
|
12
|
+
this.code = code;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { ProfileError };
|
|
19
18
|
//# sourceMappingURL=errors.js.map
|