@robinpath/retry 0.1.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/README.md +93 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/retry.d.ts +139 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +302 -0
- package/dist/retry.js.map +1 -0
- package/package.json +14 -0
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# @robinpath/retry
|
|
2
|
+
|
|
3
|
+
> Retry with exponential backoff and circuit breaker patterns for resilient automation workflows
|
|
4
|
+
|
|
5
|
+
   
|
|
6
|
+
|
|
7
|
+
## Why use this module?
|
|
8
|
+
|
|
9
|
+
The `retry` module lets you:
|
|
10
|
+
|
|
11
|
+
- Execute a function with automatic retry and exponential backoff
|
|
12
|
+
- Calculate the delay for a given retry attempt using exponential backoff
|
|
13
|
+
- Check if an HTTP status code is retryable (408, 429, 500, 502, 503, 504)
|
|
14
|
+
- Wait for a specified number of milliseconds
|
|
15
|
+
- Preview the delay schedule for a series of retry attempts
|
|
16
|
+
|
|
17
|
+
All functions are callable directly from RobinPath scripts with a simple, consistent API.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @robinpath/retry
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
No credentials needed — start using it right away:
|
|
28
|
+
|
|
29
|
+
```robinpath
|
|
30
|
+
retry.withBackoff 3 1000 2 30000
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Available Functions
|
|
34
|
+
|
|
35
|
+
| Function | Description |
|
|
36
|
+
|----------|-------------|
|
|
37
|
+
| `retry.execute` | Execute a function with automatic retry and exponential backoff |
|
|
38
|
+
| `retry.withBackoff` | Calculate the delay for a given retry attempt using exponential backoff |
|
|
39
|
+
| `retry.isRetryable` | Check if an HTTP status code is retryable (408, 429, 500, 502, 503, 504) |
|
|
40
|
+
| `retry.delay` | Wait for a specified number of milliseconds |
|
|
41
|
+
| `retry.attempts` | Preview the delay schedule for a series of retry attempts |
|
|
42
|
+
| `retry.createBreaker` | Create a named circuit breaker with a failure threshold and reset timeout |
|
|
43
|
+
| `retry.breakerState` | Get the current state of a named circuit breaker |
|
|
44
|
+
| `retry.breakerRecord` | Record a success or failure in a circuit breaker |
|
|
45
|
+
| `retry.breakerAllow` | Check if a circuit breaker allows requests through |
|
|
46
|
+
| `retry.breakerReset` | Reset a circuit breaker to closed state |
|
|
47
|
+
|
|
48
|
+
## Examples
|
|
49
|
+
|
|
50
|
+
### Calculate the delay for a given retry attempt using exponential backoff
|
|
51
|
+
|
|
52
|
+
```robinpath
|
|
53
|
+
retry.withBackoff 3 1000 2 30000
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Check if an HTTP status code is retryable (408, 429, 500, 502, 503, 504)
|
|
57
|
+
|
|
58
|
+
```robinpath
|
|
59
|
+
retry.isRetryable 503
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Wait for a specified number of milliseconds
|
|
63
|
+
|
|
64
|
+
```robinpath
|
|
65
|
+
retry.delay 2000
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Integration with RobinPath
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { RobinPath } from "@wiredwp/robinpath";
|
|
72
|
+
import Module from "@robinpath/retry";
|
|
73
|
+
|
|
74
|
+
const rp = new RobinPath();
|
|
75
|
+
rp.registerModule(Module.name, Module.functions);
|
|
76
|
+
rp.registerModuleMeta(Module.name, Module.functionMetadata);
|
|
77
|
+
|
|
78
|
+
const result = await rp.executeScript(`
|
|
79
|
+
retry.withBackoff 3 1000 2 30000
|
|
80
|
+
`);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Full API Reference
|
|
84
|
+
|
|
85
|
+
See [MODULE.md](./MODULE.md) for complete documentation including all parameters, return types, error handling, and advanced examples.
|
|
86
|
+
|
|
87
|
+
## Related Modules
|
|
88
|
+
|
|
89
|
+
- [`@robinpath/json`](../json) — JSON module for complementary functionality
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ModuleAdapter } from "@wiredwp/robinpath";
|
|
2
|
+
declare const RetryModule: ModuleAdapter;
|
|
3
|
+
export default RetryModule;
|
|
4
|
+
export { RetryModule };
|
|
5
|
+
export { RetryFunctions, RetryFunctionMetadata, RetryModuleMetadata } from "./retry.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD,QAAA,MAAM,WAAW,EAAE,aAMlB,CAAC;AAEF,eAAe,WAAW,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RetryFunctions, RetryFunctionMetadata, RetryModuleMetadata } from "./retry.js";
|
|
2
|
+
const RetryModule = {
|
|
3
|
+
name: "retry",
|
|
4
|
+
functions: RetryFunctions,
|
|
5
|
+
functionMetadata: RetryFunctionMetadata,
|
|
6
|
+
moduleMetadata: RetryModuleMetadata,
|
|
7
|
+
global: false,
|
|
8
|
+
}; // as ModuleAdapter
|
|
9
|
+
export default RetryModule;
|
|
10
|
+
export { RetryModule };
|
|
11
|
+
export { RetryFunctions, RetryFunctionMetadata, RetryModuleMetadata } from "./retry.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAExF,MAAM,WAAW,GAAkB;IACjC,IAAI,EAAE,OAAO;IACb,SAAS,EAAE,cAAc;IACzB,gBAAgB,EAAE,qBAA4B;IAC9C,cAAc,EAAE,mBAA0B;IAC1C,MAAM,EAAE,KAAK;CACd,CAAC,CAAC,mBAAmB;AAEtB,eAAe,WAAW,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/retry.d.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { BuiltinHandler } from "@wiredwp/robinpath";
|
|
2
|
+
export declare const RetryFunctions: Record<string, BuiltinHandler>;
|
|
3
|
+
export declare const RetryFunctionMetadata: {
|
|
4
|
+
execute: {
|
|
5
|
+
description: string;
|
|
6
|
+
parameters: {
|
|
7
|
+
name: string;
|
|
8
|
+
dataType: string;
|
|
9
|
+
description: string;
|
|
10
|
+
formInputType: string;
|
|
11
|
+
required: boolean;
|
|
12
|
+
}[];
|
|
13
|
+
returnType: string;
|
|
14
|
+
returnDescription: string;
|
|
15
|
+
example: string;
|
|
16
|
+
};
|
|
17
|
+
withBackoff: {
|
|
18
|
+
description: string;
|
|
19
|
+
parameters: {
|
|
20
|
+
name: string;
|
|
21
|
+
dataType: string;
|
|
22
|
+
description: string;
|
|
23
|
+
formInputType: string;
|
|
24
|
+
required: boolean;
|
|
25
|
+
}[];
|
|
26
|
+
returnType: string;
|
|
27
|
+
returnDescription: string;
|
|
28
|
+
example: string;
|
|
29
|
+
};
|
|
30
|
+
isRetryable: {
|
|
31
|
+
description: string;
|
|
32
|
+
parameters: {
|
|
33
|
+
name: string;
|
|
34
|
+
dataType: string;
|
|
35
|
+
description: string;
|
|
36
|
+
formInputType: string;
|
|
37
|
+
required: boolean;
|
|
38
|
+
}[];
|
|
39
|
+
returnType: string;
|
|
40
|
+
returnDescription: string;
|
|
41
|
+
example: string;
|
|
42
|
+
};
|
|
43
|
+
delay: {
|
|
44
|
+
description: string;
|
|
45
|
+
parameters: {
|
|
46
|
+
name: string;
|
|
47
|
+
dataType: string;
|
|
48
|
+
description: string;
|
|
49
|
+
formInputType: string;
|
|
50
|
+
required: boolean;
|
|
51
|
+
}[];
|
|
52
|
+
returnType: string;
|
|
53
|
+
returnDescription: string;
|
|
54
|
+
example: string;
|
|
55
|
+
};
|
|
56
|
+
attempts: {
|
|
57
|
+
description: string;
|
|
58
|
+
parameters: {
|
|
59
|
+
name: string;
|
|
60
|
+
dataType: string;
|
|
61
|
+
description: string;
|
|
62
|
+
formInputType: string;
|
|
63
|
+
required: boolean;
|
|
64
|
+
}[];
|
|
65
|
+
returnType: string;
|
|
66
|
+
returnDescription: string;
|
|
67
|
+
example: string;
|
|
68
|
+
};
|
|
69
|
+
createBreaker: {
|
|
70
|
+
description: string;
|
|
71
|
+
parameters: {
|
|
72
|
+
name: string;
|
|
73
|
+
dataType: string;
|
|
74
|
+
description: string;
|
|
75
|
+
formInputType: string;
|
|
76
|
+
required: boolean;
|
|
77
|
+
}[];
|
|
78
|
+
returnType: string;
|
|
79
|
+
returnDescription: string;
|
|
80
|
+
example: string;
|
|
81
|
+
};
|
|
82
|
+
breakerState: {
|
|
83
|
+
description: string;
|
|
84
|
+
parameters: {
|
|
85
|
+
name: string;
|
|
86
|
+
dataType: string;
|
|
87
|
+
description: string;
|
|
88
|
+
formInputType: string;
|
|
89
|
+
required: boolean;
|
|
90
|
+
}[];
|
|
91
|
+
returnType: string;
|
|
92
|
+
returnDescription: string;
|
|
93
|
+
example: string;
|
|
94
|
+
};
|
|
95
|
+
breakerRecord: {
|
|
96
|
+
description: string;
|
|
97
|
+
parameters: {
|
|
98
|
+
name: string;
|
|
99
|
+
dataType: string;
|
|
100
|
+
description: string;
|
|
101
|
+
formInputType: string;
|
|
102
|
+
required: boolean;
|
|
103
|
+
}[];
|
|
104
|
+
returnType: string;
|
|
105
|
+
returnDescription: string;
|
|
106
|
+
example: string;
|
|
107
|
+
};
|
|
108
|
+
breakerAllow: {
|
|
109
|
+
description: string;
|
|
110
|
+
parameters: {
|
|
111
|
+
name: string;
|
|
112
|
+
dataType: string;
|
|
113
|
+
description: string;
|
|
114
|
+
formInputType: string;
|
|
115
|
+
required: boolean;
|
|
116
|
+
}[];
|
|
117
|
+
returnType: string;
|
|
118
|
+
returnDescription: string;
|
|
119
|
+
example: string;
|
|
120
|
+
};
|
|
121
|
+
breakerReset: {
|
|
122
|
+
description: string;
|
|
123
|
+
parameters: {
|
|
124
|
+
name: string;
|
|
125
|
+
dataType: string;
|
|
126
|
+
description: string;
|
|
127
|
+
formInputType: string;
|
|
128
|
+
required: boolean;
|
|
129
|
+
}[];
|
|
130
|
+
returnType: string;
|
|
131
|
+
returnDescription: string;
|
|
132
|
+
example: string;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
export declare const RetryModuleMetadata: {
|
|
136
|
+
description: string;
|
|
137
|
+
methods: string[];
|
|
138
|
+
};
|
|
139
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAA2C,MAAM,oBAAoB,CAAC;AAwOlG,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAWzD,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqGjC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;CAG/B,CAAC"}
|
package/dist/retry.js
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
const breakers = new Map();
|
|
2
|
+
const DEFAULT_OPTIONS = {
|
|
3
|
+
maxAttempts: 3,
|
|
4
|
+
initialDelay: 1000,
|
|
5
|
+
maxDelay: 30000,
|
|
6
|
+
backoffFactor: 2,
|
|
7
|
+
retryOn: [],
|
|
8
|
+
jitter: true,
|
|
9
|
+
};
|
|
10
|
+
// ── Helpers ─────────────────────────────────────────────────────────
|
|
11
|
+
function sleep(ms) {
|
|
12
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
13
|
+
}
|
|
14
|
+
function calculateDelay(attempt, options) {
|
|
15
|
+
let delay = options.initialDelay * Math.pow(options.backoffFactor, attempt);
|
|
16
|
+
delay = Math.min(delay, options.maxDelay);
|
|
17
|
+
if (options.jitter) {
|
|
18
|
+
delay = delay * (0.5 + Math.random() * 0.5);
|
|
19
|
+
}
|
|
20
|
+
return Math.round(delay);
|
|
21
|
+
}
|
|
22
|
+
function parseOptions(args) {
|
|
23
|
+
const opts = (typeof args[0] === "object" && args[0] !== null ? args[0] : {});
|
|
24
|
+
return { ...DEFAULT_OPTIONS, ...opts };
|
|
25
|
+
}
|
|
26
|
+
// ── Function Handlers ───────────────────────────────────────────────
|
|
27
|
+
const execute = async (args) => {
|
|
28
|
+
const fn = args[0];
|
|
29
|
+
const opts = parseOptions(args.slice(1));
|
|
30
|
+
if (typeof fn !== "function") {
|
|
31
|
+
throw new Error("First argument must be a callable function");
|
|
32
|
+
}
|
|
33
|
+
let lastError;
|
|
34
|
+
for (let attempt = 0; attempt < opts.maxAttempts; attempt++) {
|
|
35
|
+
try {
|
|
36
|
+
const result = await fn();
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
lastError = err;
|
|
41
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
42
|
+
if (opts.retryOn.length > 0 && !opts.retryOn.some((s) => message.includes(s))) {
|
|
43
|
+
throw err;
|
|
44
|
+
}
|
|
45
|
+
if (attempt < opts.maxAttempts - 1) {
|
|
46
|
+
const delay = calculateDelay(attempt, opts);
|
|
47
|
+
await sleep(delay);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
throw lastError;
|
|
52
|
+
};
|
|
53
|
+
const withBackoff = (args) => {
|
|
54
|
+
const attempt = parseInt(String(args[0] ?? "0"), 10);
|
|
55
|
+
const initialDelay = parseInt(String(args[1] ?? "1000"), 10);
|
|
56
|
+
const factor = parseFloat(String(args[2] ?? "2"));
|
|
57
|
+
const maxDelay = parseInt(String(args[3] ?? "30000"), 10);
|
|
58
|
+
const jitter = args[4] !== false && args[4] !== "false";
|
|
59
|
+
let delay = initialDelay * Math.pow(factor, attempt);
|
|
60
|
+
delay = Math.min(delay, maxDelay);
|
|
61
|
+
if (jitter) {
|
|
62
|
+
delay = delay * (0.5 + Math.random() * 0.5);
|
|
63
|
+
}
|
|
64
|
+
return Math.round(delay);
|
|
65
|
+
};
|
|
66
|
+
const isRetryable = (args) => {
|
|
67
|
+
const statusCode = parseInt(String(args[0] ?? "0"), 10);
|
|
68
|
+
// Retryable HTTP status codes: 408 (timeout), 429 (too many), 500, 502, 503, 504
|
|
69
|
+
const retryableCodes = [408, 429, 500, 502, 503, 504];
|
|
70
|
+
return retryableCodes.includes(statusCode);
|
|
71
|
+
};
|
|
72
|
+
const delay = async (args) => {
|
|
73
|
+
const ms = parseInt(String(args[0] ?? "1000"), 10);
|
|
74
|
+
await sleep(ms);
|
|
75
|
+
return true;
|
|
76
|
+
};
|
|
77
|
+
const attempts = (args) => {
|
|
78
|
+
const maxAttempts = parseInt(String(args[0] ?? "3"), 10);
|
|
79
|
+
const initialDelay = parseInt(String(args[1] ?? "1000"), 10);
|
|
80
|
+
const factor = parseFloat(String(args[2] ?? "2"));
|
|
81
|
+
const result = [];
|
|
82
|
+
let totalWait = 0;
|
|
83
|
+
for (let i = 0; i < maxAttempts; i++) {
|
|
84
|
+
const d = i === 0 ? 0 : Math.round(initialDelay * Math.pow(factor, i - 1));
|
|
85
|
+
totalWait += d;
|
|
86
|
+
result.push({ attempt: i + 1, delay: d, totalWait });
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
89
|
+
};
|
|
90
|
+
// ── Circuit Breaker ─────────────────────────────────────────────────
|
|
91
|
+
const createBreaker = (args) => {
|
|
92
|
+
const name = String(args[0] ?? "default");
|
|
93
|
+
const threshold = parseInt(String(args[1] ?? "5"), 10);
|
|
94
|
+
const resetTimeout = parseInt(String(args[2] ?? "60000"), 10);
|
|
95
|
+
const state = {
|
|
96
|
+
failures: 0,
|
|
97
|
+
threshold,
|
|
98
|
+
resetTimeout,
|
|
99
|
+
state: "closed",
|
|
100
|
+
lastFailure: 0,
|
|
101
|
+
successesInHalfOpen: 0,
|
|
102
|
+
halfOpenThreshold: 1,
|
|
103
|
+
};
|
|
104
|
+
breakers.set(name, state);
|
|
105
|
+
return { name, state: state.state, threshold, resetTimeout };
|
|
106
|
+
};
|
|
107
|
+
const breakerState = (args) => {
|
|
108
|
+
const name = String(args[0] ?? "default");
|
|
109
|
+
const b = breakers.get(name);
|
|
110
|
+
if (!b)
|
|
111
|
+
return { name, state: "unknown" };
|
|
112
|
+
// Check if open breaker should transition to half-open
|
|
113
|
+
if (b.state === "open" && Date.now() - b.lastFailure >= b.resetTimeout) {
|
|
114
|
+
b.state = "half-open";
|
|
115
|
+
b.successesInHalfOpen = 0;
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
name,
|
|
119
|
+
state: b.state,
|
|
120
|
+
failures: b.failures,
|
|
121
|
+
threshold: b.threshold,
|
|
122
|
+
resetTimeout: b.resetTimeout,
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
const breakerRecord = (args) => {
|
|
126
|
+
const name = String(args[0] ?? "default");
|
|
127
|
+
const success = args[1] !== false && args[1] !== "false" && args[1] !== "failure";
|
|
128
|
+
const b = breakers.get(name);
|
|
129
|
+
if (!b)
|
|
130
|
+
throw new Error(`Circuit breaker "${name}" not found. Create it first.`);
|
|
131
|
+
// Check transition from open → half-open
|
|
132
|
+
if (b.state === "open" && Date.now() - b.lastFailure >= b.resetTimeout) {
|
|
133
|
+
b.state = "half-open";
|
|
134
|
+
b.successesInHalfOpen = 0;
|
|
135
|
+
}
|
|
136
|
+
if (success) {
|
|
137
|
+
if (b.state === "half-open") {
|
|
138
|
+
b.successesInHalfOpen++;
|
|
139
|
+
if (b.successesInHalfOpen >= b.halfOpenThreshold) {
|
|
140
|
+
b.state = "closed";
|
|
141
|
+
b.failures = 0;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
b.failures = 0;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
b.failures++;
|
|
150
|
+
b.lastFailure = Date.now();
|
|
151
|
+
if (b.failures >= b.threshold) {
|
|
152
|
+
b.state = "open";
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return { name, state: b.state, failures: b.failures };
|
|
156
|
+
};
|
|
157
|
+
const breakerAllow = (args) => {
|
|
158
|
+
const name = String(args[0] ?? "default");
|
|
159
|
+
const b = breakers.get(name);
|
|
160
|
+
if (!b)
|
|
161
|
+
return true;
|
|
162
|
+
if (b.state === "open") {
|
|
163
|
+
if (Date.now() - b.lastFailure >= b.resetTimeout) {
|
|
164
|
+
b.state = "half-open";
|
|
165
|
+
b.successesInHalfOpen = 0;
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
return true;
|
|
171
|
+
};
|
|
172
|
+
const breakerReset = (args) => {
|
|
173
|
+
const name = String(args[0] ?? "default");
|
|
174
|
+
const b = breakers.get(name);
|
|
175
|
+
if (!b)
|
|
176
|
+
return false;
|
|
177
|
+
b.failures = 0;
|
|
178
|
+
b.state = "closed";
|
|
179
|
+
b.lastFailure = 0;
|
|
180
|
+
b.successesInHalfOpen = 0;
|
|
181
|
+
return true;
|
|
182
|
+
};
|
|
183
|
+
// ── Exports ─────────────────────────────────────────────────────────
|
|
184
|
+
export const RetryFunctions = {
|
|
185
|
+
execute,
|
|
186
|
+
withBackoff,
|
|
187
|
+
isRetryable,
|
|
188
|
+
delay,
|
|
189
|
+
attempts,
|
|
190
|
+
createBreaker,
|
|
191
|
+
breakerState,
|
|
192
|
+
breakerRecord,
|
|
193
|
+
breakerAllow,
|
|
194
|
+
breakerReset,
|
|
195
|
+
};
|
|
196
|
+
export const RetryFunctionMetadata = {
|
|
197
|
+
execute: {
|
|
198
|
+
description: "Execute a function with automatic retry and exponential backoff",
|
|
199
|
+
parameters: [
|
|
200
|
+
{ name: "fn", dataType: "string", description: "The async function to execute", formInputType: "text", required: true },
|
|
201
|
+
{ name: "options", dataType: "object", description: "Retry options: maxAttempts, initialDelay, maxDelay, backoffFactor, retryOn, jitter", formInputType: "text", required: false },
|
|
202
|
+
],
|
|
203
|
+
returnType: "any",
|
|
204
|
+
returnDescription: "The result of the function if it succeeds within the retry limit",
|
|
205
|
+
example: 'retry.execute $myFunction {"maxAttempts": 5, "initialDelay": 2000}',
|
|
206
|
+
},
|
|
207
|
+
withBackoff: {
|
|
208
|
+
description: "Calculate the delay for a given retry attempt using exponential backoff",
|
|
209
|
+
parameters: [
|
|
210
|
+
{ name: "attempt", dataType: "number", description: "The current attempt number (0-based)", formInputType: "text", required: true },
|
|
211
|
+
{ name: "initialDelay", dataType: "number", description: "Base delay in ms (default 1000)", formInputType: "text", required: false },
|
|
212
|
+
{ name: "factor", dataType: "number", description: "Backoff multiplier (default 2)", formInputType: "text", required: false },
|
|
213
|
+
{ name: "maxDelay", dataType: "number", description: "Maximum delay in ms (default 30000)", formInputType: "text", required: false },
|
|
214
|
+
{ name: "jitter", dataType: "boolean", description: "Add random jitter (default true)", formInputType: "text", required: false },
|
|
215
|
+
],
|
|
216
|
+
returnType: "number",
|
|
217
|
+
returnDescription: "The delay in milliseconds for the given attempt",
|
|
218
|
+
example: "retry.withBackoff 3 1000 2 30000",
|
|
219
|
+
},
|
|
220
|
+
isRetryable: {
|
|
221
|
+
description: "Check if an HTTP status code is retryable (408, 429, 500, 502, 503, 504)",
|
|
222
|
+
parameters: [
|
|
223
|
+
{ name: "statusCode", dataType: "number", description: "The HTTP status code to check", formInputType: "text", required: true },
|
|
224
|
+
],
|
|
225
|
+
returnType: "boolean",
|
|
226
|
+
returnDescription: "True if the status code is typically retryable",
|
|
227
|
+
example: "retry.isRetryable 503",
|
|
228
|
+
},
|
|
229
|
+
delay: {
|
|
230
|
+
description: "Wait for a specified number of milliseconds",
|
|
231
|
+
parameters: [
|
|
232
|
+
{ name: "ms", dataType: "number", description: "Milliseconds to wait", formInputType: "text", required: true },
|
|
233
|
+
],
|
|
234
|
+
returnType: "boolean",
|
|
235
|
+
returnDescription: "True when the delay completes",
|
|
236
|
+
example: "retry.delay 2000",
|
|
237
|
+
},
|
|
238
|
+
attempts: {
|
|
239
|
+
description: "Preview the delay schedule for a series of retry attempts",
|
|
240
|
+
parameters: [
|
|
241
|
+
{ name: "maxAttempts", dataType: "number", description: "Number of attempts (default 3)", formInputType: "text", required: false },
|
|
242
|
+
{ name: "initialDelay", dataType: "number", description: "Base delay in ms (default 1000)", formInputType: "text", required: false },
|
|
243
|
+
{ name: "factor", dataType: "number", description: "Backoff multiplier (default 2)", formInputType: "text", required: false },
|
|
244
|
+
],
|
|
245
|
+
returnType: "array",
|
|
246
|
+
returnDescription: "Array of {attempt, delay, totalWait} objects",
|
|
247
|
+
example: "retry.attempts 5 1000 2",
|
|
248
|
+
},
|
|
249
|
+
createBreaker: {
|
|
250
|
+
description: "Create a named circuit breaker with a failure threshold and reset timeout",
|
|
251
|
+
parameters: [
|
|
252
|
+
{ name: "name", dataType: "string", description: "Circuit breaker name", formInputType: "text", required: true },
|
|
253
|
+
{ name: "threshold", dataType: "number", description: "Number of failures before opening (default 5)", formInputType: "text", required: false },
|
|
254
|
+
{ name: "resetTimeout", dataType: "number", description: "Time in ms before transitioning to half-open (default 60000)", formInputType: "text", required: false },
|
|
255
|
+
],
|
|
256
|
+
returnType: "object",
|
|
257
|
+
returnDescription: "The circuit breaker configuration",
|
|
258
|
+
example: 'retry.createBreaker "api-service" 3 30000',
|
|
259
|
+
},
|
|
260
|
+
breakerState: {
|
|
261
|
+
description: "Get the current state of a named circuit breaker",
|
|
262
|
+
parameters: [
|
|
263
|
+
{ name: "name", dataType: "string", description: "Circuit breaker name", formInputType: "text", required: true },
|
|
264
|
+
],
|
|
265
|
+
returnType: "object",
|
|
266
|
+
returnDescription: "Object with state (closed/open/half-open), failures, threshold",
|
|
267
|
+
example: 'retry.breakerState "api-service"',
|
|
268
|
+
},
|
|
269
|
+
breakerRecord: {
|
|
270
|
+
description: "Record a success or failure in a circuit breaker",
|
|
271
|
+
parameters: [
|
|
272
|
+
{ name: "name", dataType: "string", description: "Circuit breaker name", formInputType: "text", required: true },
|
|
273
|
+
{ name: "success", dataType: "boolean", description: "True for success, false or 'failure' for failure", formInputType: "text", required: true },
|
|
274
|
+
],
|
|
275
|
+
returnType: "object",
|
|
276
|
+
returnDescription: "Updated circuit breaker state",
|
|
277
|
+
example: 'retry.breakerRecord "api-service" false',
|
|
278
|
+
},
|
|
279
|
+
breakerAllow: {
|
|
280
|
+
description: "Check if a circuit breaker allows requests through",
|
|
281
|
+
parameters: [
|
|
282
|
+
{ name: "name", dataType: "string", description: "Circuit breaker name", formInputType: "text", required: true },
|
|
283
|
+
],
|
|
284
|
+
returnType: "boolean",
|
|
285
|
+
returnDescription: "True if requests are allowed, false if circuit is open",
|
|
286
|
+
example: 'retry.breakerAllow "api-service"',
|
|
287
|
+
},
|
|
288
|
+
breakerReset: {
|
|
289
|
+
description: "Reset a circuit breaker to closed state",
|
|
290
|
+
parameters: [
|
|
291
|
+
{ name: "name", dataType: "string", description: "Circuit breaker name", formInputType: "text", required: true },
|
|
292
|
+
],
|
|
293
|
+
returnType: "boolean",
|
|
294
|
+
returnDescription: "True if reset successfully",
|
|
295
|
+
example: 'retry.breakerReset "api-service"',
|
|
296
|
+
},
|
|
297
|
+
};
|
|
298
|
+
export const RetryModuleMetadata = {
|
|
299
|
+
description: "Retry with exponential backoff and circuit breaker patterns for resilient automation workflows",
|
|
300
|
+
methods: ["execute", "withBackoff", "isRetryable", "delay", "attempts", "createBreaker", "breakerState", "breakerRecord", "breakerAllow", "breakerReset"],
|
|
301
|
+
};
|
|
302
|
+
//# sourceMappingURL=retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAuBA,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA+B,CAAC;AAExD,MAAM,eAAe,GAAiB;IACpC,WAAW,EAAE,CAAC;IACd,YAAY,EAAE,IAAI;IAClB,QAAQ,EAAE,KAAK;IACf,aAAa,EAAE,CAAC;IAChB,OAAO,EAAE,EAAE;IACX,MAAM,EAAE,IAAI;CACb,CAAC;AAEF,uEAAuE;AAEvE,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,cAAc,CAAC,OAAe,EAAE,OAAqB;IAC5D,IAAI,KAAK,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC5E,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC1C,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,KAAK,GAAG,KAAK,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,E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iBAAiB,EAAE,wDAAwD;QAC3E,OAAO,EAAE,kCAAkC;KAC5C;IACD,YAAY,EAAE;QACZ,WAAW,EAAE,yCAAyC;QACtD,UAAU,EAAE;YACV,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;SACjH;QACD,UAAU,EAAE,SAAS;QACrB,iBAAiB,EAAE,4BAA4B;QAC/C,OAAO,EAAE,kCAAkC;KAC5C;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,WAAW,EAAE,gGAAgG;IAC7G,OAAO,EAAE,CAAC,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,CAAC;CAC1J,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@robinpath/retry",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Retry with exponential backoff and circuit breaker for RobinPath",
|
|
5
|
+
"publishConfig": { "access": "public" },
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": { ".": { "import": "./dist/index.js", "types": "./dist/index.d.ts" } },
|
|
10
|
+
"files": ["dist"],
|
|
11
|
+
"scripts": { "build": "tsc", "test": "node --import tsx --test tests/*.test.ts" },
|
|
12
|
+
"peerDependencies": { "@wiredwp/robinpath": ">=0.20.0" },
|
|
13
|
+
"devDependencies": { "@wiredwp/robinpath": "^0.30.1", "tsx": "^4.19.0", "typescript": "^5.6.0" }
|
|
14
|
+
}
|