Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 08:51
    mergify[bot] labeled #6953
  • 08:51
    mergify[bot] labeled #6953
  • 08:50
    Quafadas opened #6953
  • 08:02
    gringrape review_requested #6944
  • 03:38
    reardonj edited #307
  • 03:38
    reardonj opened #307
  • 03:30
    reardonj opened #306
  • 03:16
    reardonj commented #293
  • 03:12
    armanbilge commented #293
  • 03:10
    reardonj commented #293
  • 02:38
    gringrape synchronize #6944
  • Jan 31 20:22

    github-actions[bot] on gh-pages

    deploy: 4ee392ff78a0196a9be91bc… (compare)

  • Jan 31 20:17

    armanbilge on ignore-jmh-main

    (compare)

  • Jan 31 20:17

    armanbilge on main

    Ignore sbt-jmh updates on main … Merge pull request #6952 from h… (compare)

  • Jan 31 20:17
    armanbilge closed #6952
  • Jan 31 18:28
    armanbilge commented #6952
  • Jan 31 18:22
    valencik commented #6952
  • Jan 31 18:01

    github-actions[bot] on gh-pages

    deploy: 71477556de26849ca59c9f3… (compare)

  • Jan 31 17:53

    armanbilge on series

    (compare)

  • Jan 31 17:53

    armanbilge on 0.23

    Update sbt-jmh to 0.4.4 in seri… Merge pull request #6951 from h… (compare)

Rob Norris
@tpolecat
No worries, it's just a throwaway thing right now.
Just trying to get distributed tracing to actually distribute. It works, so I'm good.
Christopher Davenport
@ChristopherDavenport
I'm excited, it's the only client that doesn't require effect, which means pure throughout.
Rob Norris
@tpolecat
Right. Skunk too, for the same reason.
Carlos Quiroz
@cquiroz
Could you explain that a bit for newbies
Do you mean the Effect type class?
Rob Norris
@tpolecat
yes, the blaze and async-http clients have an Effect constraint
so this means your F[A] can't be Kleisli[G, E, A] because you need an E before you have any hope of getting an A out, so you can't write Kleisli[G, E, A] => A which is basically what Effect is.
So the "reader" effect is incompatible with Effect. You can never have both.
So. Getting rid of an Effect constraint is a big deal.
Ross A. Baker
@rossabaker
I tried, but I can't remember if I tried since cats-effect-1.
I guess ember gets away with it by being one big stream? I think the problem is the request has to be an end of the world in most backends.
Rob Norris
@tpolecat
I guess it comes down to the particulars. fs2 does nio sockets without Effect.
Michael Pilquist
@mpilquist
Oh hey, I spent my Friday evening on this: functional-streams-for-scala/fs2#1497
Which led me to propose typelevel/cats-effect#555
@tpolecat Would especially like your feedback on the fs2.io.tcp changes given your usage in skunk
Rob Norris
@tpolecat
Oh cool. Yeah I’ll check it out. My talk has to take a detour to deal with ACG.
Packing and loafing around atm but I’ll have a look on ze plane.
Toby Thain
@toby5box
I've asked this before I think but… I have a rather deep and complicated bunch of code that produces a ConnectionIO[], and now I need a side-effecty IO value deep inside it… so it would save me a lot of work if I could use ConnectionIO as IO. what's the accepted way to do this again?
(the IO wraps a random UUID)
Fabio Labella
@SystemFw
liftIO
in this case it's fine because even though you cannot rollback the IO inside, it's not a big deal
Toby Thain
@toby5box
thanks! lemme see…
Rob Norris
@tpolecat
IO(...).to[ConnectionIO]
Toby Thain
@toby5box

IO(...).to[ConnectionIO]

thanks, smartypants

Rohde Fischer
@rfftrifork
is there any good ways to mock/stub/whatever for a http4s client in testing? I've always had a bad taste about mocking frameworks,because I end up testing that a specific method is called, rather than the specific result. E.g., if I have a service that use the client I want to know that http://foo is called, I want to simulate the response "bar" and that my service gives "baz". I do not (seen from the test) care if this is done using expect, getAs or some other way
Fabio Labella
@SystemFw
@rfftrifork you can use Client.fromHttpApp, which takes an http4s server definition and gives you a client that calls that server
no actual http is involved so you can actually use it in unit tests
Rohde Fischer
@rfftrifork
@SystemFw oooooohhhhhh sounds exactly like what I want, thanks once again, mate :) You're a great help (y)
Fabio Labella
@SystemFw
:+1:
Rohde Fischer
@rohdef
is it correct that the only reasonable ways to reach the Response object is either via run or the error callbacks?
Rohde Fischer
@rohdef
because that seems slightly weird to me :) especially since I don't want to translate http errors in to exceptions (by default at least), rather I'd like to react selectively on them, e.g. a Not Found might result in a message about creating the resource where a Request Timeout might be cause for using a circuit breaker with exponential timeout and so on, where an exception is something I'd use more for code issues, such as if I try to pass an malformed url to a method
(what I'm trying to say, it's two very different kinds of errors, and I'd like to treat them accordingly :p )
Fabio Labella
@SystemFw
are you talking about the client? there is fetch for access to the whole response
Rohde Fischer
@rohdef
@SystemFw yes I am :) so you'd do something along the lines of (semi pseudocode, I'm slow at writing scala code right now, since my code completion plugin is broken... for once running a pre-release backfires):
def foo() = {
    val req = ...
    client.fetch(req)(x => {
        if (x.status == OK) { /* do this /* }
        else if (x.status == ReuqestTimeout) { /* do that */ }
       //...
    }).unsafeRunSync()
}
Fabio Labella
@SystemFw
no unsafeRunSync. You can do that though yeah, there are a bunch of ways. The other things you mentioned like the error callbacks or handling exceptions though recoverWith are also ok
Ross A. Baker
@rossabaker
Statuses are also extractors: you can do things like case Ok(resp) => ...
Rohde Fischer
@rohdef
@SystemFw at some point my IOs needs to be run. Now I haven't looked in to that part, but the first client I intend to run timed, so running the IO might come naturally if the scheduler does it, but otherwise how would you run the IO at the end?
Fabio Labella
@SystemFw
your whole application ends up being one IO, at which point you use IOApp which has main: IO[ExitCode]
you do need to run it manually if you are integrating http4s in a non functional codebase though
Rohde Fischer
@rohdef

@rossabaker ah my other savior :) that might be what I'm looking for indeed, so running:

client.status(req).map(x match {
    case ...
})

is that correctly understood?

Fabio Labella
@SystemFw
if you only care about the status code and not the body, you can do that
I think Ross was saying that inside fetch you can use an extractor like case Ok(resp) instead of if (x.status == ....)
Ross A. Baker
@rossabaker
It might be helpful to peruse the source of DefaultClient and you can see how they're implemented in terms of the others.
Fabio Labella
@SystemFw
basically replacing if else with match
Ross A. Baker
@rossabaker
Yes, exactly.
Rohde Fischer
@rohdef
oh... and the dime drops (I think at least)
Fabio Labella
@SystemFw
second the suggestion of looking at some of the methods in DefaultClient
Ross A. Baker
@rossabaker
There are also status class extractors... you can do Successful, ClientError, etc. for 2xx, 4xx, etc.
4p