Created
January 4, 2022 23:33
-
-
Save lambda-mike/13450ee8c371a862ef23da936f8e6c02 to your computer and use it in GitHub Desktop.
Schedule example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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