@distilled.cloud/planetscale 0.16.2 → 0.16.3
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.d.ts.map +1 -1
- package/lib/client.js +8 -2
- package/lib/client.js.map +1 -1
- package/lib/retry.d.ts +22 -13
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +22 -12
- package/lib/retry.js.map +1 -1
- package/package.json +2 -2
- package/src/client.ts +11 -1
- package/src/retry.ts +30 -12
package/lib/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAWxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAwC/C;;GAEG;AACH,eAAO,MAAM,GAAG;;;CASd,CAAC"}
|
package/lib/client.js
CHANGED
|
@@ -8,6 +8,8 @@ import * as Effect from "effect/Effect";
|
|
|
8
8
|
import * as Redacted from "effect/Redacted";
|
|
9
9
|
import * as Schema from "effect/Schema";
|
|
10
10
|
import { makeAPI } from "@distilled.cloud/core/client";
|
|
11
|
+
import { parseRetryAfterForStatus } from "@distilled.cloud/core/retry-after";
|
|
12
|
+
import { Retry } from "./retry.js";
|
|
11
13
|
import { HTTP_STATUS_MAP, UnknownPlanetScaleError, PlanetScaleParseError, } from "./errors.js";
|
|
12
14
|
// Re-export for backwards compatibility (tests import UnknownPlanetScaleError from client)
|
|
13
15
|
export { UnknownPlanetScaleError } from "./errors.js";
|
|
@@ -20,12 +22,15 @@ const ApiErrorResponse = Schema.Struct({
|
|
|
20
22
|
/**
|
|
21
23
|
* Match a PlanetScale API error response to the appropriate error class.
|
|
22
24
|
*/
|
|
23
|
-
const matchError = (status, errorBody) => {
|
|
25
|
+
const matchError = (status, errorBody, _errors, headers) => {
|
|
24
26
|
try {
|
|
25
27
|
const parsed = Schema.decodeUnknownSync(ApiErrorResponse)(errorBody);
|
|
26
28
|
const ErrorClass = HTTP_STATUS_MAP[status];
|
|
27
29
|
if (ErrorClass) {
|
|
28
|
-
return Effect.fail(new ErrorClass({
|
|
30
|
+
return Effect.fail(new ErrorClass({
|
|
31
|
+
message: parsed.message ?? "",
|
|
32
|
+
retryAfter: parseRetryAfterForStatus(status, headers),
|
|
33
|
+
}));
|
|
29
34
|
}
|
|
30
35
|
return Effect.fail(new UnknownPlanetScaleError({
|
|
31
36
|
code: parsed.code,
|
|
@@ -48,5 +53,6 @@ export const API = makeAPI({
|
|
|
48
53
|
}),
|
|
49
54
|
matchError,
|
|
50
55
|
ParseError: PlanetScaleParseError,
|
|
56
|
+
retry: Retry,
|
|
51
57
|
});
|
|
52
58
|
//# sourceMappingURL=client.js.map
|
package/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAErB,2FAA2F;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,4BAA4B;AAC5B,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;CACxC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,UAAU,GAAG,CACjB,MAAc,EACd,SAAkB,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAErB,2FAA2F;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,4BAA4B;AAC5B,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;CACxC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,UAAU,GAAG,CACjB,MAAc,EACd,SAAkB,EAClB,OAA4B,EAC5B,OAA4C,EACb,EAAE;IACjC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,SAAS,CAAC,CAAC;QACrE,MAAM,UAAU,GAAI,eAAuB,CAAC,MAAM,CAAC,CAAC;QACpD,IAAI,UAAU,EAAE,CAAC;YACf,OAAO,MAAM,CAAC,IAAI,CAChB,IAAI,UAAU,CAAC;gBACb,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,EAAE;gBAC7B,UAAU,EAAE,wBAAwB,CAAC,MAAM,EAAE,OAAO,CAAC;aACtD,CAAC,CACH,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,CAChB,IAAI,uBAAuB,CAAC;YAC1B,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,IAAI,EAAE,SAAS;SAChB,CAAC,CACH,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,uBAAuB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACvE,CAAC;AACH,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,OAAO,CAAc;IACtC,WAAW,EAAE,WAAkB;IAC/B,UAAU,EAAE,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU;IAC5C,cAAc,EAAE,CAAC,KAAU,EAAE,EAAE,CAAC,CAAC;QAC/B,aAAa,EAAE,GAAG,KAAK,CAAC,OAAO,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;KACjE,CAAC;IACF,UAAU;IACV,UAAU,EAAE,qBAA4B;IACxC,KAAK,EAAE,KAAY;CACpB,CAAC,CAAC"}
|
package/lib/retry.d.ts
CHANGED
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* PlanetScale retry configuration.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Defines the per-SDK `Retry` Context.Service tag that
|
|
5
|
+
* `packages/planetscale/src/client.ts` wires into `makeAPI`. Callers can
|
|
6
|
+
* install a blanket retry policy at the layer level and have every
|
|
7
|
+
* PlanetScale API call below it pick it up:
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import * as PlanetScale from "@distilled.cloud/planetscale";
|
|
12
|
+
*
|
|
13
|
+
* myEffect.pipe(PlanetScale.Retry.transient);
|
|
14
|
+
* Effect.provide(myEffect, Layer.succeed(PlanetScale.Retry.Retry, customPolicy));
|
|
15
|
+
* ```
|
|
5
16
|
*/
|
|
6
|
-
import * as Effect from "effect/Effect";
|
|
7
17
|
import * as Context from "effect/Context";
|
|
8
|
-
|
|
9
|
-
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";
|
|
10
21
|
declare const Retry_base: Context.ServiceClass<Retry, "PlanetScaleRetry", Policy>;
|
|
11
|
-
/**
|
|
12
|
-
* Context tag for configuring retry behavior of PlanetScale API calls.
|
|
13
|
-
*/
|
|
22
|
+
/** Context tag for configuring retry behavior of PlanetScale API calls. */
|
|
14
23
|
export declare class Retry extends Retry_base {
|
|
15
24
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Provides a custom retry policy to all PlanetScale API calls.
|
|
18
|
-
*/
|
|
25
|
+
/** Provides a custom retry policy to every PlanetScale API call below it. */
|
|
19
26
|
export declare const policy: (optionsOrFactory: Policy) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
20
|
-
/**
|
|
21
|
-
* Disables all automatic retries.
|
|
22
|
-
*/
|
|
27
|
+
/** Disables all automatic retries. */
|
|
23
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>>;
|
|
24
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,2EAA2E;AAC3E,qBAAa,KAAM,SAAQ,UAE1B;CAAG;AAEJ,6EAA6E;AAC7E,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,23 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* PlanetScale retry configuration.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Defines the per-SDK `Retry` Context.Service tag that
|
|
5
|
+
* `packages/planetscale/src/client.ts` wires into `makeAPI`. Callers can
|
|
6
|
+
* install a blanket retry policy at the layer level and have every
|
|
7
|
+
* PlanetScale API call below it pick it up:
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import * as PlanetScale from "@distilled.cloud/planetscale";
|
|
12
|
+
*
|
|
13
|
+
* myEffect.pipe(PlanetScale.Retry.transient);
|
|
14
|
+
* Effect.provide(myEffect, Layer.succeed(PlanetScale.Retry.Retry, customPolicy));
|
|
15
|
+
* ```
|
|
5
16
|
*/
|
|
17
|
+
import * as Context from "effect/Context";
|
|
6
18
|
import * as Effect from "effect/Effect";
|
|
7
19
|
import * as Layer from "effect/Layer";
|
|
8
|
-
import
|
|
9
|
-
export { makeDefault, jittered, capped, throttlingOptions, transientOptions, } from "@distilled.cloud/core/retry";
|
|
10
|
-
/**
|
|
11
|
-
* Context tag for configuring retry behavior of PlanetScale API calls.
|
|
12
|
-
*/
|
|
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 PlanetScale API calls. */
|
|
13
23
|
export class Retry extends Context.Service()("PlanetScaleRetry") {
|
|
14
24
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Provides a custom retry policy to all PlanetScale API calls.
|
|
17
|
-
*/
|
|
25
|
+
/** Provides a custom retry policy to every PlanetScale API call below it. */
|
|
18
26
|
export const policy = (optionsOrFactory) => Effect.provide(Layer.succeed(Retry, optionsOrFactory));
|
|
19
|
-
/**
|
|
20
|
-
* Disables all automatic retries.
|
|
21
|
-
*/
|
|
27
|
+
/** Disables all automatic retries. */
|
|
22
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);
|
|
23
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,2EAA2E;AAC3E,MAAM,OAAO,KAAM,SAAQ,OAAO,CAAC,OAAO,EAAiB,CACzD,kBAAkB,CACnB;CAAG;AAEJ,6EAA6E;AAC7E,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/planetscale",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/alchemy-run/distilled",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"specs:update": "git -C specs/distilled-spec-planetscale fetch && git -C specs/distilled-spec-planetscale checkout main && git -C specs/distilled-spec-planetscale pull"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@distilled.cloud/core": "0.16.
|
|
76
|
+
"@distilled.cloud/core": "0.16.3",
|
|
77
77
|
"effect": "4.0.0-beta.58"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
package/src/client.ts
CHANGED
|
@@ -8,6 +8,8 @@ import * as Effect from "effect/Effect";
|
|
|
8
8
|
import * as Redacted from "effect/Redacted";
|
|
9
9
|
import * as Schema from "effect/Schema";
|
|
10
10
|
import { makeAPI } from "@distilled.cloud/core/client";
|
|
11
|
+
import { parseRetryAfterForStatus } from "@distilled.cloud/core/retry-after";
|
|
12
|
+
import { Retry } from "./retry.ts";
|
|
11
13
|
import {
|
|
12
14
|
HTTP_STATUS_MAP,
|
|
13
15
|
UnknownPlanetScaleError,
|
|
@@ -30,12 +32,19 @@ const ApiErrorResponse = Schema.Struct({
|
|
|
30
32
|
const matchError = (
|
|
31
33
|
status: number,
|
|
32
34
|
errorBody: unknown,
|
|
35
|
+
_errors?: readonly unknown[],
|
|
36
|
+
headers?: Record<string, string | undefined>,
|
|
33
37
|
): Effect.Effect<never, unknown> => {
|
|
34
38
|
try {
|
|
35
39
|
const parsed = Schema.decodeUnknownSync(ApiErrorResponse)(errorBody);
|
|
36
40
|
const ErrorClass = (HTTP_STATUS_MAP as any)[status];
|
|
37
41
|
if (ErrorClass) {
|
|
38
|
-
return Effect.fail(
|
|
42
|
+
return Effect.fail(
|
|
43
|
+
new ErrorClass({
|
|
44
|
+
message: parsed.message ?? "",
|
|
45
|
+
retryAfter: parseRetryAfterForStatus(status, headers),
|
|
46
|
+
}),
|
|
47
|
+
);
|
|
39
48
|
}
|
|
40
49
|
return Effect.fail(
|
|
41
50
|
new UnknownPlanetScaleError({
|
|
@@ -60,4 +69,5 @@ export const API = makeAPI<Credentials>({
|
|
|
60
69
|
}),
|
|
61
70
|
matchError,
|
|
62
71
|
ParseError: PlanetScaleParseError as any,
|
|
72
|
+
retry: Retry as any,
|
|
63
73
|
});
|
package/src/retry.ts
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* PlanetScale retry configuration.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Defines the per-SDK `Retry` Context.Service tag that
|
|
5
|
+
* `packages/planetscale/src/client.ts` wires into `makeAPI`. Callers can
|
|
6
|
+
* install a blanket retry policy at the layer level and have every
|
|
7
|
+
* PlanetScale API call below it pick it up:
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import * as PlanetScale from "@distilled.cloud/planetscale";
|
|
12
|
+
*
|
|
13
|
+
* myEffect.pipe(PlanetScale.Retry.transient);
|
|
14
|
+
* Effect.provide(myEffect, Layer.succeed(PlanetScale.Retry.Retry, customPolicy));
|
|
15
|
+
* ```
|
|
5
16
|
*/
|
|
17
|
+
import * as Context from "effect/Context";
|
|
6
18
|
import * as Effect from "effect/Effect";
|
|
7
19
|
import * as Layer from "effect/Layer";
|
|
8
|
-
import
|
|
20
|
+
import {
|
|
21
|
+
type Policy,
|
|
22
|
+
throttlingFactory,
|
|
23
|
+
transientFactory,
|
|
24
|
+
} from "@distilled.cloud/core/retry";
|
|
25
|
+
|
|
9
26
|
export {
|
|
10
27
|
type Options,
|
|
11
28
|
type Factory,
|
|
@@ -15,25 +32,26 @@ export {
|
|
|
15
32
|
capped,
|
|
16
33
|
throttlingOptions,
|
|
17
34
|
transientOptions,
|
|
35
|
+
throttlingFactory,
|
|
36
|
+
transientFactory,
|
|
18
37
|
} from "@distilled.cloud/core/retry";
|
|
19
|
-
import type { Policy } from "@distilled.cloud/core/retry";
|
|
20
38
|
|
|
21
|
-
/**
|
|
22
|
-
* Context tag for configuring retry behavior of PlanetScale API calls.
|
|
23
|
-
*/
|
|
39
|
+
/** Context tag for configuring retry behavior of PlanetScale API calls. */
|
|
24
40
|
export class Retry extends Context.Service<Retry, Policy>()(
|
|
25
41
|
"PlanetScaleRetry",
|
|
26
42
|
) {}
|
|
27
43
|
|
|
28
|
-
/**
|
|
29
|
-
* Provides a custom retry policy to all PlanetScale API calls.
|
|
30
|
-
*/
|
|
44
|
+
/** Provides a custom retry policy to every PlanetScale API call below it. */
|
|
31
45
|
export const policy = (optionsOrFactory: Policy) =>
|
|
32
46
|
Effect.provide(Layer.succeed(Retry, optionsOrFactory));
|
|
33
47
|
|
|
34
|
-
/**
|
|
35
|
-
* Disables all automatic retries.
|
|
36
|
-
*/
|
|
48
|
+
/** Disables all automatic retries. */
|
|
37
49
|
export const none = Effect.provide(
|
|
38
50
|
Layer.succeed(Retry, { while: () => false }),
|
|
39
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);
|