Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 05 2019 14:43
    @typelevel-bot banned @jdegoes
  • Jan 31 2019 21:17
    codecov-io commented #484
  • Jan 31 2019 21:08
    scala-steward opened #484
  • Jan 31 2019 18:19
    andywhite37 commented #189
  • Jan 31 2019 02:41
    kamilongus starred typelevel/cats-effect
  • Jan 30 2019 00:01
    codecov-io commented #483
  • Jan 29 2019 23:51
    deniszjukow opened #483
  • Jan 29 2019 23:37
  • Jan 29 2019 23:22
  • Jan 29 2019 20:26
    Rui-L starred typelevel/cats-effect
  • Jan 29 2019 18:01
    jdegoes commented #480
  • Jan 29 2019 17:04
    thomaav starred typelevel/cats-effect
  • Jan 28 2019 17:43
    asachdeva starred typelevel/cats-effect
  • Jan 28 2019 07:12
    alexandru commented #480
  • Jan 28 2019 05:45
    codecov-io commented #482
  • Jan 28 2019 05:35
    daron666 opened #482
  • Jan 27 2019 13:56
    codecov-io commented #481
  • Jan 27 2019 13:46
    lrodero opened #481
  • Jan 27 2019 05:47
    codecov-io commented #460
  • Jan 27 2019 05:37
    codecov-io commented #460
Nicolas Francois
@Koisell
If it's release before Scala 3 which is probable
Daniel Spiewak
@djspiewak
I'll set up a highlight, which will cause Twitch to keep the video forever
it'll be interesting because I had to split the stream a bit, but should be fine
Ross A. Baker
@rossabaker
Wonderful talk. Thanks for doing that.
Daniel Spiewak
@djspiewak
Thanks to everyone who came! I’d love to do more of that sort of thing, especially now that the technical stuff is sorted.
Christopher Davenport
@ChristopherDavenport
Can't wait to see it once I'm back from strangeloop, thanks for saving it.
Ryan Peters
@sloshy
+1 really excited to listen in! Maybe I'll play it on the drive home. Is it mostly audio-friendly?
Daniel Spiewak
@djspiewak
Should be pretty audio friendly
davidnadeau
@davidnadeau
So i'm using akka, and this bindAnHandle function forks off and returns immediately, which means my main IO program just ends. So I'm using IO.never to prevent the program from ending. Is this a valid usuage off IO.never, or will this cause issues?
    for {
      _ <- IO
        .fromFuture(IO(Http().bindAndHandle(routes, settings.httpInterface, settings.httpPort)))
        .bracket { serverBinding =>
          actorSystem.log.info("API listens on {}", serverBinding.localAddress)
          IO.never
        }(serverBinding => IO(serverBinding.terminate(1.minute)))
    } yield ()
Christopher Davenport
@ChristopherDavenport
Can't promise it won't cause issues, but it's a fairly common pattern when servers return immediately.
Daniel Spiewak
@djspiewak
I usually create an async around it and have the callback complete when the server closes
Or if the server has a separate shutdown function, I would use a Resource
davidnadeau
@davidnadeau
Resource would make this much nicer to read, i'll definitely be using that.
davidnadeau
@davidnadeau
something like this i guess
_ <- akkaHttpResource(routes).use { serverBinding =>
        actorSystem.log.info("API listens on {}", serverBinding.localAddress)
        Async[IO].never
    }
davidnadeau
@davidnadeau
@ChristopherDavenport what sort of issues could you forsee this pattern causing?
Jakub Kozłowski
@kubukoz
I do this in production everywhere. No issues so far
With akka.
davidnadeau
@davidnadeau
good to know
chet khatri
@chetkhatri
@kubukoz could you share sample with akka on that. Thanks
chet khatri
@chetkhatri
@rossabaker @djspiewak great documentation - https://typelevel.org/cats-effect/datatypes/io.html I have gone through this. well explained.
Jakub Kozłowski
@kubukoz

@chetkhatri for akka http servers I do this:

def httpServer(routes: Routes): Resource[IO, ServerBinding] = {
   val serverF = IO.deferFuture {
    IO{
        Http().bindAndHandle(
          routes,
          config.http.host,
          config.http.port
        )
    }
  }
  Resource.make(serverF)(server => IO.fromFuture(IO(server.unbind())).void)
}

Then use it like this:

def run(args: List[String]): IO[ExitCode] = {
  val appResource: Resource[F, Unit] = for {
    service1 <- ...
    service2 <- ...
    _ <- httpServer(service1.routes ~ service2.routes)
  } yield ()

  appResource.use(_ => IO.never)
}
minus formatting because I'm too lazy
Ryan Zeigler
@rzeigler
API design question. Does it make sense to include a close action in my trait algebras if the expectation is they should always be used as resources anyway?
Oleg Pyzhcov
@oleg-py
My preference is no - exiting from .use is enough, and it only buys you an ability to crash something else that is using same object.
Jakub Kozłowski
@kubukoz
same here - close the resource in a Resource'sclose and that's it
Piotr Gawryś
@Avasil
Agreed, if you use Resource then close can be dangerous
Jakub Kozłowski
@kubukoz
so the above snippets should actually return an immutable clone of ServerBinding that doesn't include unbind.
or make it a Resource[F, Unit], which is actually fine :)
Ryan Zeigler
@rzeigler
:thumbsup:
Jakub Kozłowski
@kubukoz
a bit harder to do if your resource is ActorSystem.
Ryan Zeigler
@rzeigler
heh
no
i'm writing a wire protocol client that is derived from fs2.Socket which does expose a close but none of my higher things do
so the question occured to me
Jakub Kozłowski
@kubukoz
yeah it still feels strange to me that it's there
Ross A. Baker
@rossabaker
We ripped out shutdown functions on http4s resources when they became Resources. No regrets. I think it makes things simpler.
bifunctor
@bifunctor_gitlab
what does it mean So it is useful for suspending effects
?
What does suspending effects mean?
Gavin Bisesi
@Daenyth
it means that you can construct an IO which wraps a side effect but doesn't execute it until the IO executes
val hi: IO[Unit] = IO(println("hi")) <- prints nothing when constructing hi
bifunctor
@bifunctor_gitlab
Thanks a loty
lot
What does Asynchronous boundaries mean in context with https://typelevel.org/cats-effect/datatypes/io.html#concurrency-and-cancellation
Daniel Spiewak
@djspiewak
an asynchronous boundary is usually something like a thread pool yield
like really anything that's going to take a callback, then later on invoke it
bifunctor
@bifunctor_gitlab
@djspiewak thanks a lot
Daniel Spiewak
@djspiewak
np
Adrian Legaspi
@akilegaspi
just a question, why the cats-effect typelevel page doesn't have the same community announcements as the cats typelevel page?