Last active
May 17, 2021 14:28
-
-
Save natansil/8763a0d11dda1db83b4ccd99947c6f62 to your computer and use it in GitHub Desktop.
This file contains 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
object DefectNotHandledExample extends App { | |
import zio._ | |
import zio.duration._ | |
override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = | |
for { | |
_ <- runSomePeriodicJob | |
.catchAll(e => console.putStrLn(s"job failed with $e")) | |
.repeat(Schedule.spaced(1.seconds)) | |
.forkDaemon | |
_ <- console.putStrLn("do other stuff") | |
.repeat(Schedule.spaced(1.seconds)) | |
} yield ExitCode(0) | |
private def runSomePeriodicJob = { | |
ZIO.succeed(throw new RuntimeException("unexpected defect")) *> ZIO.effect(println("running job...")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment