@distilled.cloud/expo-eas 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.d.ts.map +1 -1
- package/lib/client.js +12 -3
- package/lib/client.js.map +1 -1
- package/lib/retry.d.ts +25 -14
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +25 -13
- package/lib/retry.js.map +1 -1
- package/package.json +2 -2
- package/src/client.ts +23 -4
- package/src/retry.ts +33 -13
package/lib/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAYxC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AA+G/C;;GAEG;AACH,eAAO,MAAM,GAAG;;;CASd,CAAC"}
|
package/lib/client.js
CHANGED
|
@@ -23,6 +23,8 @@ import * as Effect from "effect/Effect";
|
|
|
23
23
|
import * as Redacted from "effect/Redacted";
|
|
24
24
|
import * as Schema from "effect/Schema";
|
|
25
25
|
import { makeAPI } from "@distilled.cloud/core/client";
|
|
26
|
+
import { parseRetryAfterForStatus } from "@distilled.cloud/core/retry-after";
|
|
27
|
+
import { Retry } from "./retry.js";
|
|
26
28
|
import { HTTP_STATUS_MAP, UnknownEasError, EasParseError, EAS_ERROR_CODE_MAP, } from "./errors.js";
|
|
27
29
|
// Re-export for backwards compatibility with consumers importing from ./client
|
|
28
30
|
export { UnknownEasError } from "./errors.js";
|
|
@@ -56,7 +58,7 @@ const decodeRest = Schema.decodeUnknownOption(RestErrorResponse);
|
|
|
56
58
|
* Match an EAS error response (GraphQL envelope or HTTP-level body) to the
|
|
57
59
|
* appropriate error class.
|
|
58
60
|
*/
|
|
59
|
-
const matchError = (status, errorBody) => {
|
|
61
|
+
const matchError = (status, errorBody, _errors, headers) => {
|
|
60
62
|
// Try GraphQL envelope first — works for both HTTP 200 with errors[] and
|
|
61
63
|
// HTTP 400 responses returned by the GraphQL gateway.
|
|
62
64
|
const envelope = decodeEnvelope(errorBody);
|
|
@@ -72,7 +74,10 @@ const matchError = (status, errorBody) => {
|
|
|
72
74
|
}
|
|
73
75
|
const StatusClass = HTTP_STATUS_MAP[status];
|
|
74
76
|
if (StatusClass && status >= 400) {
|
|
75
|
-
return Effect.fail(new StatusClass({
|
|
77
|
+
return Effect.fail(new StatusClass({
|
|
78
|
+
message,
|
|
79
|
+
retryAfter: parseRetryAfterForStatus(status, headers),
|
|
80
|
+
}));
|
|
76
81
|
}
|
|
77
82
|
return Effect.fail(new UnknownEasError({
|
|
78
83
|
code,
|
|
@@ -85,7 +90,10 @@ const matchError = (status, errorBody) => {
|
|
|
85
90
|
if (rest._tag === "Some") {
|
|
86
91
|
const StatusClass = HTTP_STATUS_MAP[status];
|
|
87
92
|
if (StatusClass) {
|
|
88
|
-
return Effect.fail(new StatusClass({
|
|
93
|
+
return Effect.fail(new StatusClass({
|
|
94
|
+
message: rest.value.message ?? "",
|
|
95
|
+
retryAfter: parseRetryAfterForStatus(status, headers),
|
|
96
|
+
}));
|
|
89
97
|
}
|
|
90
98
|
return Effect.fail(new UnknownEasError({
|
|
91
99
|
code: rest.value.code,
|
|
@@ -106,5 +114,6 @@ export const API = makeAPI({
|
|
|
106
114
|
}),
|
|
107
115
|
matchError,
|
|
108
116
|
ParseError: EasParseError,
|
|
117
|
+
retry: Retry,
|
|
109
118
|
});
|
|
110
119
|
//# sourceMappingURL=client.js.map
|
package/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts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AC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,CAChB,IAAI,eAAe,CAAC;YAClB,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;YACrB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;YAC3B,IAAI,EAAE,SAAS;SAChB,CAAC,CACH,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,eAAe,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;AAC/D,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,UAAU,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE;KAC7D,CAAC;IACF,UAAU;IACV,UAAU,EAAE,aAAoB;IAChC,KAAK,EAAE,KAAY;CACpB,CAAC,CAAC"}
|
package/lib/retry.d.ts
CHANGED
|
@@ -1,22 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* ExpoEas retry configuration.
|
|
3
|
+
*
|
|
4
|
+
* Defines the per-SDK `Retry` Context.Service tag that
|
|
5
|
+
* `packages/expo-eas/src/client.ts` wires into `makeAPI`. Callers can
|
|
6
|
+
* install a blanket retry policy at the layer level and have every
|
|
7
|
+
* ExpoEas API call below it pick it up:
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import * as ExpoEas from "@distilled.cloud/expo-eas";
|
|
12
|
+
*
|
|
13
|
+
* myEffect.pipe(ExpoEas.Retry.transient);
|
|
14
|
+
* Effect.provide(myEffect, Layer.succeed(ExpoEas.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
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
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";
|
|
21
|
+
declare const Retry_base: Context.ServiceClass<Retry, "ExpoEasRetry", Policy>;
|
|
22
|
+
/** Context tag for configuring retry behavior of ExpoEas API calls. */
|
|
12
23
|
export declare class Retry extends Retry_base {
|
|
13
24
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Provides a custom retry policy to all Eas API calls.
|
|
16
|
-
*/
|
|
25
|
+
/** Provides a custom retry policy to every ExpoEas 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,uEAAuE;AACvE,qBAAa,KAAM,SAAQ,UAAgD;CAAG;AAE9E,yEAAyE;AACzE,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
|
+
* ExpoEas retry configuration.
|
|
3
|
+
*
|
|
4
|
+
* Defines the per-SDK `Retry` Context.Service tag that
|
|
5
|
+
* `packages/expo-eas/src/client.ts` wires into `makeAPI`. Callers can
|
|
6
|
+
* install a blanket retry policy at the layer level and have every
|
|
7
|
+
* ExpoEas API call below it pick it up:
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import * as ExpoEas from "@distilled.cloud/expo-eas";
|
|
12
|
+
*
|
|
13
|
+
* myEffect.pipe(ExpoEas.Retry.transient);
|
|
14
|
+
* Effect.provide(myEffect, Layer.succeed(ExpoEas.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
|
-
|
|
10
|
-
*/
|
|
11
|
-
export class Retry extends Context.Service()("EasRetry") {
|
|
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 ExpoEas API calls. */
|
|
23
|
+
export class Retry extends Context.Service()("ExpoEasRetry") {
|
|
12
24
|
}
|
|
13
|
-
/**
|
|
14
|
-
* Provides a custom retry policy to all Eas API calls.
|
|
15
|
-
*/
|
|
25
|
+
/** Provides a custom retry policy to every ExpoEas 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,uEAAuE;AACvE,MAAM,OAAO,KAAM,SAAQ,OAAO,CAAC,OAAO,EAAiB,CAAC,cAAc,CAAC;CAAG;AAE9E,yEAAyE;AACzE,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/expo-eas",
|
|
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",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"specs:update": "git -C specs/eas-cli fetch && git -C specs/eas-cli checkout main && git -C specs/eas-cli pull && git -C specs/expo fetch && git -C specs/expo checkout main && git -C specs/expo pull"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@distilled.cloud/core": "0.16.
|
|
76
|
+
"@distilled.cloud/core": "0.16.4",
|
|
77
77
|
"effect": "4.0.0-beta.58"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
package/src/client.ts
CHANGED
|
@@ -23,6 +23,8 @@ import * as Effect from "effect/Effect";
|
|
|
23
23
|
import * as Redacted from "effect/Redacted";
|
|
24
24
|
import * as Schema from "effect/Schema";
|
|
25
25
|
import { makeAPI } from "@distilled.cloud/core/client";
|
|
26
|
+
import { parseRetryAfterForStatus } from "@distilled.cloud/core/retry-after";
|
|
27
|
+
import { Retry } from "./retry.ts";
|
|
26
28
|
import {
|
|
27
29
|
HTTP_STATUS_MAP,
|
|
28
30
|
UnknownEasError,
|
|
@@ -72,6 +74,8 @@ const decodeRest = Schema.decodeUnknownOption(RestErrorResponse);
|
|
|
72
74
|
const matchError = (
|
|
73
75
|
status: number,
|
|
74
76
|
errorBody: unknown,
|
|
77
|
+
_errors?: readonly unknown[],
|
|
78
|
+
headers?: Record<string, string | undefined>,
|
|
75
79
|
): Effect.Effect<never, unknown> => {
|
|
76
80
|
// Try GraphQL envelope first — works for both HTTP 200 with errors[] and
|
|
77
81
|
// HTTP 400 responses returned by the GraphQL gateway.
|
|
@@ -89,10 +93,18 @@ const matchError = (
|
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
const StatusClass = (HTTP_STATUS_MAP as Record<number, unknown>)[status] as
|
|
92
|
-
| (new (args: {
|
|
96
|
+
| (new (args: {
|
|
97
|
+
message: string;
|
|
98
|
+
retryAfter?: ReturnType<typeof parseRetryAfterForStatus>;
|
|
99
|
+
}) => unknown)
|
|
93
100
|
| undefined;
|
|
94
101
|
if (StatusClass && status >= 400) {
|
|
95
|
-
return Effect.fail(
|
|
102
|
+
return Effect.fail(
|
|
103
|
+
new StatusClass({
|
|
104
|
+
message,
|
|
105
|
+
retryAfter: parseRetryAfterForStatus(status, headers),
|
|
106
|
+
}) as never,
|
|
107
|
+
);
|
|
96
108
|
}
|
|
97
109
|
|
|
98
110
|
return Effect.fail(
|
|
@@ -108,11 +120,17 @@ const matchError = (
|
|
|
108
120
|
const rest = decodeRest(errorBody);
|
|
109
121
|
if (rest._tag === "Some") {
|
|
110
122
|
const StatusClass = (HTTP_STATUS_MAP as Record<number, unknown>)[status] as
|
|
111
|
-
| (new (args: {
|
|
123
|
+
| (new (args: {
|
|
124
|
+
message: string;
|
|
125
|
+
retryAfter?: ReturnType<typeof parseRetryAfterForStatus>;
|
|
126
|
+
}) => unknown)
|
|
112
127
|
| undefined;
|
|
113
128
|
if (StatusClass) {
|
|
114
129
|
return Effect.fail(
|
|
115
|
-
new StatusClass({
|
|
130
|
+
new StatusClass({
|
|
131
|
+
message: rest.value.message ?? "",
|
|
132
|
+
retryAfter: parseRetryAfterForStatus(status, headers),
|
|
133
|
+
}) as never,
|
|
116
134
|
);
|
|
117
135
|
}
|
|
118
136
|
return Effect.fail(
|
|
@@ -138,4 +156,5 @@ export const API = makeAPI<Credentials>({
|
|
|
138
156
|
}),
|
|
139
157
|
matchError,
|
|
140
158
|
ParseError: EasParseError as any,
|
|
159
|
+
retry: Retry as any,
|
|
141
160
|
});
|
package/src/retry.ts
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* ExpoEas retry configuration.
|
|
3
|
+
*
|
|
4
|
+
* Defines the per-SDK `Retry` Context.Service tag that
|
|
5
|
+
* `packages/expo-eas/src/client.ts` wires into `makeAPI`. Callers can
|
|
6
|
+
* install a blanket retry policy at the layer level and have every
|
|
7
|
+
* ExpoEas API call below it pick it up:
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import * as ExpoEas from "@distilled.cloud/expo-eas";
|
|
12
|
+
*
|
|
13
|
+
* myEffect.pipe(ExpoEas.Retry.transient);
|
|
14
|
+
* Effect.provide(myEffect, Layer.succeed(ExpoEas.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,23 +32,24 @@ 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
|
-
|
|
21
|
-
*/
|
|
22
|
-
export class Retry extends Context.Service<Retry, Policy>()("EasRetry") {}
|
|
39
|
+
/** Context tag for configuring retry behavior of ExpoEas API calls. */
|
|
40
|
+
export class Retry extends Context.Service<Retry, Policy>()("ExpoEasRetry") {}
|
|
23
41
|
|
|
24
|
-
/**
|
|
25
|
-
* Provides a custom retry policy to all Eas API calls.
|
|
26
|
-
*/
|
|
42
|
+
/** Provides a custom retry policy to every ExpoEas API call below it. */
|
|
27
43
|
export const policy = (optionsOrFactory: Policy) =>
|
|
28
44
|
Effect.provide(Layer.succeed(Retry, optionsOrFactory));
|
|
29
45
|
|
|
30
|
-
/**
|
|
31
|
-
* Disables all automatic retries.
|
|
32
|
-
*/
|
|
46
|
+
/** Disables all automatic retries. */
|
|
33
47
|
export const none = Effect.provide(
|
|
34
48
|
Layer.succeed(Retry, { while: () => false }),
|
|
35
49
|
);
|
|
50
|
+
|
|
51
|
+
/** Apply the throttling retry policy (retries throttling errors indefinitely). */
|
|
52
|
+
export const throttling = policy(throttlingFactory);
|
|
53
|
+
|
|
54
|
+
/** Apply the transient retry policy (retries all transient errors indefinitely). */
|
|
55
|
+
export const transient = policy(transientFactory);
|