Skip to content

Instantly share code, notes, and snippets.

@lambda-mike
Created January 4, 2022 23:33
Show Gist options
  • Save lambda-mike/13450ee8c371a862ef23da936f8e6c02 to your computer and use it in GitHub Desktop.
Save lambda-mike/13450ee8c371a862ef23da936f8e6c02 to your computer and use it in GitHub Desktop.
Schedule example
import * as SC from "@effect-ts/core/Effect/Schedule"
import { pipe } from "@effect-ts/core/Function"
const app1 = pipe(
T.fail("app1"),
T.retry(pipe(
//SC.exponential(1000, 2)["&&"](SC.recurs(4))["|>"](SC.jittered_),
SC.exponential(1000, 2)["&&"](SC.recurs(4)),
SC.onDecision((d) => {
console.log("app1", d);
return T.succeed(null);
}),
)),
);
const ticTac = pipe(
T.succeedWith(() => console.log(new Date().toUTCString())),
T.delay(1000),
T.forever,
);
const main = (): Promise<void> => {
return pipe(
app1,
T.zipLeftPar(ticTac),
T.runPromise,
);
};
(async () => {
try {
await main();
} catch (err) {
console.log("Unexpected error captured:", err)
} finally {
process.exit(0);
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment