IO
and Cats Effect in general
val longProcess = (IO.sleep(5.seconds) *> IO(println("Ping!"))).foreverM val srv: Resource[IO, ServerBinding[IO]] = for { _ <- longProcess.background server <- server.run } yield server val application = srv.use(binding => IO(println("Bound to " + binding)) *> IO.never)
What's server.run ?
@WickedUk_gitlab where's that example from? looks like http4s.
do you mean what is the type of server.run
? or what are the execution semantics when it happens "after" the background
?
background
, but you're using background
as the non-essential thing when looking from "the outside", which is about starting some server) and not confuse people with the details (server.run
isn't defined in the snippet).
I'm usually afraid of asking questions on github, because I don't want to clutter it with a (probably silly) questions that (probably) was already answered many times before
Don't be afraid! I'd rather reply and close tickets that have been answered previously rather than risk someone having a question that they didn't find an answer to
val longProcess = (IO.sleep(5.seconds) *> IO(println("Ping!"))).foreverM val srv: Resource[IO, ServerBinding[IO]] = for { _ <- longProcess.background server <- server.run } yield server val application = srv.use(binding => IO(println("Bound to " + binding)) *> IO.never)
What's server.run ?
@WickedUk_gitlab where's that example from? looks like http4s.
It's cats-effect Concurrency.background scaladoc.