Created
May 22, 2021 17:01
-
-
Save natansil/6de2db5004e584e444fcbee277b4ab36 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 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