Skip to content

Commit 99d76ba

Browse files
guergaboGabriel Guerra
and
Gabriel Guerra
authored
fix(retry): export retry so users can configure the retry policy (#96)
* fix(retry): export retry so users can confugre the retry policy * fix(linter): the linting gods strike again * fix(typo) --------- Co-authored-by: Gabriel Guerra <[email protected]>
1 parent b48fe99 commit 99d76ba

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

examples/async/app.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
import { Resonate, Context } from "@resonatehq/sdk";
1+
import { Resonate, Context, Retry } from "@resonatehq/sdk";
22

3-
const resonate = new Resonate();
3+
const resonate = new Resonate({
4+
timeout: 1000,
5+
retry: Retry.exponential(
6+
100, // initial delay (in ms)
7+
2, // backoff factor
8+
Infinity, // max attempts
9+
60000, // max delay (in ms, 1 minute)
10+
),
11+
});
412

513
resonate.register("app", (ctx: Context) => {
614
return "Hello World";

lib/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ export { ResonatePromises, ResonateSchedules } from "./resonate";
33

44
// async
55
export { Resonate, Context } from "./async";
6+
7+
// resonate configurations
8+
export { Retry } from "./core/retries/retry";

package-lock.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/async.test.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ describe("Functions: async", () => {
3737
test("success", async () => {
3838
const resonate = new Resonate({
3939
timeout: 1000,
40-
retry: Retry.linear(0, 3),
40+
retry: Retry.exponential(
41+
100, // initial delay (in ms)
42+
2, // backoff factor
43+
Infinity, // max attempts
44+
60000, // max delay (in ms, 1 minute)
45+
),
4146
});
4247

4348
resonate.register("run", run);

0 commit comments

Comments
 (0)