@distilled.cloud/azure 0.16.1 → 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 +12 -3
- package/lib/client.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.ts +17 -2
- package/src/retry.ts +31 -11
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;AAUxC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAwHhD;;;;;GAKG;AACH,eAAO,MAAM,GAAG;;;CAkCd,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, AZURE_ERROR_CODE_MAP, UnknownAzureError, AzureParseError, } from "./errors.js";
|
|
27
29
|
import { Credentials } from "./credentials.js";
|
|
28
30
|
// Re-export for backwards compatibility
|
|
@@ -54,7 +56,7 @@ const FlatErrorResponse = Schema.Struct({
|
|
|
54
56
|
* 1. The error.code field (ResourceNotFound, AuthorizationFailed, etc.)
|
|
55
57
|
* 2. HTTP status code (400, 401, 403, 404, 409, 429, 500+)
|
|
56
58
|
*/
|
|
57
|
-
const matchError = (status, errorBody) => {
|
|
59
|
+
const matchError = (status, errorBody, _errors, headers) => {
|
|
58
60
|
// Try the ARM envelope format first: { error: { code, message } }
|
|
59
61
|
try {
|
|
60
62
|
const parsed = Schema.decodeUnknownSync(AzureErrorResponse)(errorBody);
|
|
@@ -71,7 +73,10 @@ const matchError = (status, errorBody) => {
|
|
|
71
73
|
// Fall back to standard HTTP status errors
|
|
72
74
|
const CoreErrorClass = HTTP_STATUS_MAP[status];
|
|
73
75
|
if (CoreErrorClass) {
|
|
74
|
-
return Effect.fail(new CoreErrorClass({
|
|
76
|
+
return Effect.fail(new CoreErrorClass({
|
|
77
|
+
message: err.message ?? "",
|
|
78
|
+
retryAfter: parseRetryAfterForStatus(status, headers),
|
|
79
|
+
}));
|
|
75
80
|
}
|
|
76
81
|
return Effect.fail(new UnknownAzureError({
|
|
77
82
|
code: err.code,
|
|
@@ -86,7 +91,10 @@ const matchError = (status, errorBody) => {
|
|
|
86
91
|
const parsed = Schema.decodeUnknownSync(FlatErrorResponse)(errorBody);
|
|
87
92
|
const ErrorClass = HTTP_STATUS_MAP[status];
|
|
88
93
|
if (ErrorClass) {
|
|
89
|
-
return Effect.fail(new ErrorClass({
|
|
94
|
+
return Effect.fail(new ErrorClass({
|
|
95
|
+
message: parsed.message ?? "",
|
|
96
|
+
retryAfter: parseRetryAfterForStatus(status, headers),
|
|
97
|
+
}));
|
|
90
98
|
}
|
|
91
99
|
return Effect.fail(new UnknownAzureError({
|
|
92
100
|
code: parsed.code,
|
|
@@ -132,6 +140,7 @@ export const API = makeAPI({
|
|
|
132
140
|
},
|
|
133
141
|
matchError,
|
|
134
142
|
ParseError: AzureParseError,
|
|
143
|
+
retry: Retry,
|
|
135
144
|
/**
|
|
136
145
|
* Inject `subscriptionId` from credentials into the path when the generated
|
|
137
146
|
* operation schema didn't fill it (i.e. the placeholder is still present).
|
package/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;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,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,wCAAwC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,8EAA8E;AAC9E,yBAAyB;AACzB,8EAA8E;AAE9E,sEAAsE;AACtE,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;CACvC,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC;IACvC,KAAK,EAAE,eAAe;CACvB,CAAC,CAAC;AAEH,gEAAgE;AAChE,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CAAC,CAAC;AAEH,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E;;;;;;GAMG;AACH,MAAM,UAAU,GAAG,CACjB,MAA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IACH,qBAAqB,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;QACnC,oEAAoE;QACpE,IAAI,sBAAsB,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;YACtE,KAAK,GAAG;gBACN,GAAG,KAAK;gBACR,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CACtB,kBAAkB,EAClB,kBAAkB,CAAC,sBAAsB,CAAC,CAC3C;aACF,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC,CAAC"}
|
package/lib/retry.d.ts
CHANGED
|
@@ -1,22 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Azure retry configuration.
|
|
3
|
+
*
|
|
4
|
+
* Defines the per-SDK `Retry` Context.Service tag that
|
|
5
|
+
* `packages/azure/src/client.ts` wires into `makeAPI`. Callers can
|
|
6
|
+
* install a blanket retry policy at the layer level and have every
|
|
7
|
+
* Azure API call below it pick it up:
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import * as Azure from "@distilled.cloud/azure";
|
|
12
|
+
*
|
|
13
|
+
* myEffect.pipe(Azure.Retry.transient);
|
|
14
|
+
* Effect.provide(myEffect, Layer.succeed(Azure.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, "AzureRetry", Policy>;
|
|
9
|
-
/**
|
|
10
|
-
* Context tag for configuring retry behavior of Azure API calls.
|
|
11
|
-
*/
|
|
22
|
+
/** Context tag for configuring retry behavior of Azure API calls. */
|
|
12
23
|
export declare class Retry extends Retry_base {
|
|
13
24
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Provides a custom retry policy to all Azure API calls.
|
|
16
|
-
*/
|
|
25
|
+
/** Provides a custom retry policy to every Azure 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,qEAAqE;AACrE,qBAAa,KAAM,SAAQ,UAA8C;CAAG;AAE5E,uEAAuE;AACvE,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
|
* Azure retry configuration.
|
|
3
|
+
*
|
|
4
|
+
* Defines the per-SDK `Retry` Context.Service tag that
|
|
5
|
+
* `packages/azure/src/client.ts` wires into `makeAPI`. Callers can
|
|
6
|
+
* install a blanket retry policy at the layer level and have every
|
|
7
|
+
* Azure API call below it pick it up:
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import * as Azure from "@distilled.cloud/azure";
|
|
12
|
+
*
|
|
13
|
+
* myEffect.pipe(Azure.Retry.transient);
|
|
14
|
+
* Effect.provide(myEffect, Layer.succeed(Azure.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 Azure 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 Azure API calls. */
|
|
11
23
|
export class Retry extends Context.Service()("AzureRetry") {
|
|
12
24
|
}
|
|
13
|
-
/**
|
|
14
|
-
* Provides a custom retry policy to all Azure API calls.
|
|
15
|
-
*/
|
|
25
|
+
/** Provides a custom retry policy to every Azure 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,qEAAqE;AACrE,MAAM,OAAO,KAAM,SAAQ,OAAO,CAAC,OAAO,EAAiB,CAAC,YAAY,CAAC;CAAG;AAE5E,uEAAuE;AACvE,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/azure",
|
|
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/azure-rest-api-specs fetch && git -C specs/azure-rest-api-specs checkout main && git -C specs/azure-rest-api-specs 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
|
@@ -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
|
AZURE_ERROR_CODE_MAP,
|
|
@@ -69,6 +71,8 @@ const FlatErrorResponse = Schema.Struct({
|
|
|
69
71
|
const matchError = (
|
|
70
72
|
status: number,
|
|
71
73
|
errorBody: unknown,
|
|
74
|
+
_errors?: readonly unknown[],
|
|
75
|
+
headers?: Record<string, string | undefined>,
|
|
72
76
|
): Effect.Effect<never, unknown> => {
|
|
73
77
|
// Try the ARM envelope format first: { error: { code, message } }
|
|
74
78
|
try {
|
|
@@ -90,7 +94,12 @@ const matchError = (
|
|
|
90
94
|
// Fall back to standard HTTP status errors
|
|
91
95
|
const CoreErrorClass = (HTTP_STATUS_MAP as any)[status];
|
|
92
96
|
if (CoreErrorClass) {
|
|
93
|
-
return Effect.fail(
|
|
97
|
+
return Effect.fail(
|
|
98
|
+
new CoreErrorClass({
|
|
99
|
+
message: err.message ?? "",
|
|
100
|
+
retryAfter: parseRetryAfterForStatus(status, headers),
|
|
101
|
+
}),
|
|
102
|
+
);
|
|
94
103
|
}
|
|
95
104
|
|
|
96
105
|
return Effect.fail(
|
|
@@ -107,7 +116,12 @@ const matchError = (
|
|
|
107
116
|
const parsed = Schema.decodeUnknownSync(FlatErrorResponse)(errorBody);
|
|
108
117
|
const ErrorClass = (HTTP_STATUS_MAP as any)[status];
|
|
109
118
|
if (ErrorClass) {
|
|
110
|
-
return Effect.fail(
|
|
119
|
+
return Effect.fail(
|
|
120
|
+
new ErrorClass({
|
|
121
|
+
message: parsed.message ?? "",
|
|
122
|
+
retryAfter: parseRetryAfterForStatus(status, headers),
|
|
123
|
+
}),
|
|
124
|
+
);
|
|
111
125
|
}
|
|
112
126
|
return Effect.fail(
|
|
113
127
|
new UnknownAzureError({
|
|
@@ -158,6 +172,7 @@ export const API = makeAPI<Credentials>({
|
|
|
158
172
|
},
|
|
159
173
|
matchError,
|
|
160
174
|
ParseError: AzureParseError as any,
|
|
175
|
+
retry: Retry as any,
|
|
161
176
|
|
|
162
177
|
/**
|
|
163
178
|
* Inject `subscriptionId` from credentials into the path when the generated
|
package/src/retry.ts
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Azure retry configuration.
|
|
3
|
+
*
|
|
4
|
+
* Defines the per-SDK `Retry` Context.Service tag that
|
|
5
|
+
* `packages/azure/src/client.ts` wires into `makeAPI`. Callers can
|
|
6
|
+
* install a blanket retry policy at the layer level and have every
|
|
7
|
+
* Azure API call below it pick it up:
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import * as Azure from "@distilled.cloud/azure";
|
|
12
|
+
*
|
|
13
|
+
* myEffect.pipe(Azure.Retry.transient);
|
|
14
|
+
* Effect.provide(myEffect, Layer.succeed(Azure.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
|
-
* Context tag for configuring retry behavior of Azure API calls.
|
|
21
|
-
*/
|
|
39
|
+
/** Context tag for configuring retry behavior of Azure API calls. */
|
|
22
40
|
export class Retry extends Context.Service<Retry, Policy>()("AzureRetry") {}
|
|
23
41
|
|
|
24
|
-
/**
|
|
25
|
-
* Provides a custom retry policy to all Azure API calls.
|
|
26
|
-
*/
|
|
42
|
+
/** Provides a custom retry policy to every Azure 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);
|