Skip to content

Instantly share code, notes, and snippets.

@natansil
Created May 22, 2021 17:01
Show Gist options
  • Save natansil/6de2db5004e584e444fcbee277b4ab36 to your computer and use it in GitHub Desktop.
Save natansil/6de2db5004e584e444fcbee277b4ab36 to your computer and use it in GitHub Desktop.
object TrackingExample extends scala.App {
def run: URIO[zio.ZEnv with FiberTracking, ExitCode] =
for {
_ <- runSomePeriodicJob.repeat(Schedule.spaced(1.seconds)).forkDaemon
fibers <- FiberTracking.fibers
fibersPretty <- Fiber.dumpStr(fibers:_*)
_ <- console.putStrLn(s">>>> tracking: $fibersPretty")
_ <- console.putStrLn("do other stuff").repeat(Schedule.spaced(1.seconds))
} yield ExitCode(0)
private def runSomePeriodicJob = {
ZIO.effect(println("running job..."))
}
Runtime.default.withFiberTracking.unsafeRun(run)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment