Last active
May 23, 2021 19:38
-
-
Save natansil/53e213cca096135ee10f5920a6b46329 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
override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = | |
for { | |
fiber <- runSomeLongJob | |
.ensuring(printWithTime("finalizing job!")) | |
.forkDaemon | |
_ <- printWithTime("do stuff").repeat(Schedule.spaced(1.seconds) && Schedule.recurs(2)) | |
timeout <- fiber.join.resurrect.ignore.disconnect.timeout(5.seconds) | |
_ <- ZIO.when(timeout.isEmpty)(fiber.interruptFork) | |
_ <- printWithTime("do other stuff").repeat(Schedule.spaced(1.seconds)) | |
} yield ExitCode(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment