@distilled.cloud/kubernetes 0.16.2 → 0.16.4
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/lib/client/api.d.ts.map +1 -1
- package/lib/client/api.js +8 -2
- package/lib/client/api.js.map +1 -1
- package/lib/retry.d.ts +23 -12
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +23 -11
- package/lib/retry.js.map +1 -1
- package/package.json +2 -2
- package/src/client/api.ts +11 -1
- package/src/retry.ts +31 -11
package/lib/client/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/client/api.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC9B,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/client/api.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC9B,MAAM,8BAA8B,CAAC;AAOtC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,YAAY,EAAE,eAAe,EAAE,wBAAwB,EAAE,CAAC;AAG1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAgFtD,eAAO,MAAM,IAAI,qUAAY,CAAC;AAC9B,eAAO,MAAM,aAAa,maAAqB,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,GAAG;;;CAAO,CAAC"}
|
package/lib/client/api.js
CHANGED
|
@@ -9,8 +9,10 @@ import * as Effect from "effect/Effect";
|
|
|
9
9
|
import * as Redacted from "effect/Redacted";
|
|
10
10
|
import * as Schema from "effect/Schema";
|
|
11
11
|
import { makeAPI, } from "@distilled.cloud/core/client";
|
|
12
|
+
import { parseRetryAfterForStatus } from "@distilled.cloud/core/retry-after";
|
|
12
13
|
import { HTTP_STATUS_MAP, UnknownKubernetesError, KubernetesParseError, } from "../errors.js";
|
|
13
14
|
import { Credentials } from "../credentials.js";
|
|
15
|
+
import { Retry } from "../retry.js";
|
|
14
16
|
// Re-export for backwards compatibility
|
|
15
17
|
export { UnknownKubernetesError } from "../errors.js";
|
|
16
18
|
/**
|
|
@@ -45,12 +47,15 @@ const ApiErrorResponse = Schema.Struct({
|
|
|
45
47
|
* "Conflict") provides additional context but the status code is the
|
|
46
48
|
* canonical discriminator used to select the error class.
|
|
47
49
|
*/
|
|
48
|
-
const matchError = (status, errorBody) => {
|
|
50
|
+
const matchError = (status, errorBody, _errors, headers) => {
|
|
49
51
|
try {
|
|
50
52
|
const parsed = Schema.decodeUnknownSync(ApiErrorResponse)(errorBody);
|
|
51
53
|
const ErrorClass = HTTP_STATUS_MAP[status];
|
|
52
54
|
if (ErrorClass) {
|
|
53
|
-
return Effect.fail(new ErrorClass({
|
|
55
|
+
return Effect.fail(new ErrorClass({
|
|
56
|
+
message: parsed.message ?? "",
|
|
57
|
+
retryAfter: parseRetryAfterForStatus(status, headers),
|
|
58
|
+
}));
|
|
54
59
|
}
|
|
55
60
|
return Effect.fail(new UnknownKubernetesError({
|
|
56
61
|
reason: parsed.reason,
|
|
@@ -75,6 +80,7 @@ const _API = makeAPI({
|
|
|
75
80
|
}),
|
|
76
81
|
matchError,
|
|
77
82
|
ParseError: KubernetesParseError,
|
|
83
|
+
retry: Retry,
|
|
78
84
|
});
|
|
79
85
|
export const make = _API.make;
|
|
80
86
|
export const makePaginated = _API.makePaginated;
|
package/lib/client/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/client/api.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,M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,CAAC,EAAE;KACvD,CAAC;IACF,UAAU;IACV,UAAU,EAAE,oBAA2B;IACvC,KAAK,EAAE,KAAY;CACpB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;AAC9B,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;AAEhD;;;GAGG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC"}
|
package/lib/retry.d.ts
CHANGED
|
@@ -1,22 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Kubernetes retry configuration.
|
|
3
|
+
*
|
|
4
|
+
* Defines the per-SDK `Retry` Context.Service tag that
|
|
5
|
+
* `packages/kubernetes/src/client.ts` wires into `makeAPI`. Callers can
|
|
6
|
+
* install a blanket retry policy at the layer level and have every
|
|
7
|
+
* Kubernetes API call below it pick it up:
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import * as Kubernetes from "@distilled.cloud/kubernetes";
|
|
12
|
+
*
|
|
13
|
+
* myEffect.pipe(Kubernetes.Retry.transient);
|
|
14
|
+
* Effect.provide(myEffect, Layer.succeed(Kubernetes.Retry.Retry, customPolicy));
|
|
15
|
+
* ```
|
|
3
16
|
*/
|
|
4
|
-
import * as Effect from "effect/Effect";
|
|
5
17
|
import * as Context from "effect/Context";
|
|
6
|
-
|
|
7
|
-
import type
|
|
18
|
+
import * as Effect from "effect/Effect";
|
|
19
|
+
import { type Policy } from "@distilled.cloud/core/retry";
|
|
20
|
+
export { type Options, type Factory, type Policy, makeDefault, jittered, capped, throttlingOptions, transientOptions, throttlingFactory, transientFactory, } from "@distilled.cloud/core/retry";
|
|
8
21
|
declare const Retry_base: Context.ServiceClass<Retry, "KubernetesRetry", Policy>;
|
|
9
|
-
/**
|
|
10
|
-
* Context tag for configuring retry behavior of Kubernetes API calls.
|
|
11
|
-
*/
|
|
22
|
+
/** Context tag for configuring retry behavior of Kubernetes API calls. */
|
|
12
23
|
export declare class Retry extends Retry_base {
|
|
13
24
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Provides a custom retry policy to all Kubernetes API calls.
|
|
16
|
-
*/
|
|
25
|
+
/** Provides a custom retry policy to every Kubernetes API call below it. */
|
|
17
26
|
export declare const policy: (optionsOrFactory: Policy) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
18
|
-
/**
|
|
19
|
-
* Disables all automatic retries.
|
|
20
|
-
*/
|
|
27
|
+
/** Disables all automatic retries. */
|
|
21
28
|
export declare const none: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
29
|
+
/** Apply the throttling retry policy (retries throttling errors indefinitely). */
|
|
30
|
+
export declare const throttling: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
31
|
+
/** Apply the transient retry policy (retries all transient errors indefinitely). */
|
|
32
|
+
export declare const transient: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
22
33
|
//# sourceMappingURL=retry.d.ts.map
|
package/lib/retry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EACL,KAAK,MAAM,EAGZ,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,MAAM,EACX,WAAW,EACX,QAAQ,EACR,MAAM,EACN,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;;AAErC,0EAA0E;AAC1E,qBAAa,KAAM,SAAQ,UAE1B;CAAG;AAEJ,4EAA4E;AAC5E,eAAO,MAAM,MAAM,qBAAsB,MAAM,sFACS,CAAC;AAEzD,sCAAsC;AACtC,eAAO,MAAM,IAAI,mFAEhB,CAAC;AAEF,kFAAkF;AAClF,eAAO,MAAM,UAAU,mFAA4B,CAAC;AAEpD,oFAAoF;AACpF,eAAO,MAAM,SAAS,mFAA2B,CAAC"}
|
package/lib/retry.js
CHANGED
|
@@ -1,21 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Kubernetes retry configuration.
|
|
3
|
+
*
|
|
4
|
+
* Defines the per-SDK `Retry` Context.Service tag that
|
|
5
|
+
* `packages/kubernetes/src/client.ts` wires into `makeAPI`. Callers can
|
|
6
|
+
* install a blanket retry policy at the layer level and have every
|
|
7
|
+
* Kubernetes API call below it pick it up:
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import * as Kubernetes from "@distilled.cloud/kubernetes";
|
|
12
|
+
*
|
|
13
|
+
* myEffect.pipe(Kubernetes.Retry.transient);
|
|
14
|
+
* Effect.provide(myEffect, Layer.succeed(Kubernetes.Retry.Retry, customPolicy));
|
|
15
|
+
* ```
|
|
3
16
|
*/
|
|
17
|
+
import * as Context from "effect/Context";
|
|
4
18
|
import * as Effect from "effect/Effect";
|
|
5
19
|
import * as Layer from "effect/Layer";
|
|
6
|
-
import
|
|
7
|
-
export { makeDefault, jittered, capped, throttlingOptions, transientOptions, } from "@distilled.cloud/core/retry";
|
|
8
|
-
/**
|
|
9
|
-
* Context tag for configuring retry behavior of Kubernetes API calls.
|
|
10
|
-
*/
|
|
20
|
+
import { throttlingFactory, transientFactory, } from "@distilled.cloud/core/retry";
|
|
21
|
+
export { makeDefault, jittered, capped, throttlingOptions, transientOptions, throttlingFactory, transientFactory, } from "@distilled.cloud/core/retry";
|
|
22
|
+
/** Context tag for configuring retry behavior of Kubernetes API calls. */
|
|
11
23
|
export class Retry extends Context.Service()("KubernetesRetry") {
|
|
12
24
|
}
|
|
13
|
-
/**
|
|
14
|
-
* Provides a custom retry policy to all Kubernetes API calls.
|
|
15
|
-
*/
|
|
25
|
+
/** Provides a custom retry policy to every Kubernetes API call below it. */
|
|
16
26
|
export const policy = (optionsOrFactory) => Effect.provide(Layer.succeed(Retry, optionsOrFactory));
|
|
17
|
-
/**
|
|
18
|
-
* Disables all automatic retries.
|
|
19
|
-
*/
|
|
27
|
+
/** Disables all automatic retries. */
|
|
20
28
|
export const none = Effect.provide(Layer.succeed(Retry, { while: () => false }));
|
|
29
|
+
/** Apply the throttling retry policy (retries throttling errors indefinitely). */
|
|
30
|
+
export const throttling = policy(throttlingFactory);
|
|
31
|
+
/** Apply the transient retry policy (retries all transient errors indefinitely). */
|
|
32
|
+
export const transient = policy(transientFactory);
|
|
21
33
|
//# sourceMappingURL=retry.js.map
|
package/lib/retry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAEL,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAIL,WAAW,EACX,QAAQ,EACR,MAAM,EACN,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AAErC,0EAA0E;AAC1E,MAAM,OAAO,KAAM,SAAQ,OAAO,CAAC,OAAO,EAAiB,CACzD,iBAAiB,CAClB;CAAG;AAEJ,4EAA4E;AAC5E,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,gBAAwB,EAAE,EAAE,CACjD,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAEzD,sCAAsC;AACtC,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAChC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,CAC7C,CAAC;AAEF,kFAAkF;AAClF,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAEpD,oFAAoF;AACpF,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@distilled.cloud/kubernetes",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/alchemy-run/distilled",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"specs:update": "git -C specs/kubernetes fetch && git -C specs/kubernetes checkout master && git -C specs/kubernetes pull"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@distilled.cloud/core": "0.16.
|
|
77
|
+
"@distilled.cloud/core": "0.16.4",
|
|
78
78
|
"effect": "4.0.0-beta.58"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
package/src/client/api.ts
CHANGED
|
@@ -13,12 +13,14 @@ import {
|
|
|
13
13
|
type OperationMethod,
|
|
14
14
|
type PaginatedOperationMethod,
|
|
15
15
|
} from "@distilled.cloud/core/client";
|
|
16
|
+
import { parseRetryAfterForStatus } from "@distilled.cloud/core/retry-after";
|
|
16
17
|
import {
|
|
17
18
|
HTTP_STATUS_MAP,
|
|
18
19
|
UnknownKubernetesError,
|
|
19
20
|
KubernetesParseError,
|
|
20
21
|
} from "../errors.ts";
|
|
21
22
|
import { Credentials } from "../credentials.ts";
|
|
23
|
+
import { Retry } from "../retry.ts";
|
|
22
24
|
|
|
23
25
|
export type { OperationMethod, PaginatedOperationMethod };
|
|
24
26
|
|
|
@@ -61,12 +63,19 @@ const ApiErrorResponse = Schema.Struct({
|
|
|
61
63
|
const matchError = (
|
|
62
64
|
status: number,
|
|
63
65
|
errorBody: unknown,
|
|
66
|
+
_errors?: readonly unknown[],
|
|
67
|
+
headers?: Record<string, string | undefined>,
|
|
64
68
|
): Effect.Effect<never, unknown> => {
|
|
65
69
|
try {
|
|
66
70
|
const parsed = Schema.decodeUnknownSync(ApiErrorResponse)(errorBody);
|
|
67
71
|
const ErrorClass = (HTTP_STATUS_MAP as any)[status];
|
|
68
72
|
if (ErrorClass) {
|
|
69
|
-
return Effect.fail(
|
|
73
|
+
return Effect.fail(
|
|
74
|
+
new ErrorClass({
|
|
75
|
+
message: parsed.message ?? "",
|
|
76
|
+
retryAfter: parseRetryAfterForStatus(status, headers),
|
|
77
|
+
}),
|
|
78
|
+
);
|
|
70
79
|
}
|
|
71
80
|
return Effect.fail(
|
|
72
81
|
new UnknownKubernetesError({
|
|
@@ -93,6 +102,7 @@ const _API = makeAPI<Credentials>({
|
|
|
93
102
|
}),
|
|
94
103
|
matchError,
|
|
95
104
|
ParseError: KubernetesParseError as any,
|
|
105
|
+
retry: Retry as any,
|
|
96
106
|
});
|
|
97
107
|
|
|
98
108
|
export const make = _API.make;
|
package/src/retry.ts
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Kubernetes retry configuration.
|
|
3
|
+
*
|
|
4
|
+
* Defines the per-SDK `Retry` Context.Service tag that
|
|
5
|
+
* `packages/kubernetes/src/client.ts` wires into `makeAPI`. Callers can
|
|
6
|
+
* install a blanket retry policy at the layer level and have every
|
|
7
|
+
* Kubernetes API call below it pick it up:
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import * as Kubernetes from "@distilled.cloud/kubernetes";
|
|
12
|
+
*
|
|
13
|
+
* myEffect.pipe(Kubernetes.Retry.transient);
|
|
14
|
+
* Effect.provide(myEffect, Layer.succeed(Kubernetes.Retry.Retry, customPolicy));
|
|
15
|
+
* ```
|
|
3
16
|
*/
|
|
17
|
+
import * as Context from "effect/Context";
|
|
4
18
|
import * as Effect from "effect/Effect";
|
|
5
19
|
import * as Layer from "effect/Layer";
|
|
6
|
-
import
|
|
20
|
+
import {
|
|
21
|
+
type Policy,
|
|
22
|
+
throttlingFactory,
|
|
23
|
+
transientFactory,
|
|
24
|
+
} from "@distilled.cloud/core/retry";
|
|
25
|
+
|
|
7
26
|
export {
|
|
8
27
|
type Options,
|
|
9
28
|
type Factory,
|
|
@@ -13,25 +32,26 @@ export {
|
|
|
13
32
|
capped,
|
|
14
33
|
throttlingOptions,
|
|
15
34
|
transientOptions,
|
|
35
|
+
throttlingFactory,
|
|
36
|
+
transientFactory,
|
|
16
37
|
} from "@distilled.cloud/core/retry";
|
|
17
|
-
import type { Policy } from "@distilled.cloud/core/retry";
|
|
18
38
|
|
|
19
|
-
/**
|
|
20
|
-
* Context tag for configuring retry behavior of Kubernetes API calls.
|
|
21
|
-
*/
|
|
39
|
+
/** Context tag for configuring retry behavior of Kubernetes API calls. */
|
|
22
40
|
export class Retry extends Context.Service<Retry, Policy>()(
|
|
23
41
|
"KubernetesRetry",
|
|
24
42
|
) {}
|
|
25
43
|
|
|
26
|
-
/**
|
|
27
|
-
* Provides a custom retry policy to all Kubernetes API calls.
|
|
28
|
-
*/
|
|
44
|
+
/** Provides a custom retry policy to every Kubernetes API call below it. */
|
|
29
45
|
export const policy = (optionsOrFactory: Policy) =>
|
|
30
46
|
Effect.provide(Layer.succeed(Retry, optionsOrFactory));
|
|
31
47
|
|
|
32
|
-
/**
|
|
33
|
-
* Disables all automatic retries.
|
|
34
|
-
*/
|
|
48
|
+
/** Disables all automatic retries. */
|
|
35
49
|
export const none = Effect.provide(
|
|
36
50
|
Layer.succeed(Retry, { while: () => false }),
|
|
37
51
|
);
|
|
52
|
+
|
|
53
|
+
/** Apply the throttling retry policy (retries throttling errors indefinitely). */
|
|
54
|
+
export const throttling = policy(throttlingFactory);
|
|
55
|
+
|
|
56
|
+
/** Apply the transient retry policy (retries all transient errors indefinitely). */
|
|
57
|
+
export const transient = policy(transientFactory);
|