Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 20:03
    codecov-commenter commented #6958
  • 19:52
    valencik synchronize #6958
  • 19:52

    valencik on jsonp-suite

    munitIgnore isNative not not is… (compare)

  • 18:53
    armanbilge edited #5010
  • 18:34
    danicheg commented #6937
  • 18:27
    danicheg commented #6958
  • 18:27
    armanbilge commented #6937
  • 18:27
    rossabaker commented #6958
  • 18:25
    rossabaker commented #6958
  • 18:23
    rossabaker synchronize #6958
  • 18:23

    rossabaker on jsonp-suite

    Complicate the Jsonp regex (compare)

  • 18:06
    rossabaker commented #6959
  • 16:52
    rossabaker commented #6960
  • 16:44
    rossabaker commented #6960
  • 16:40
    armanbilge commented #6960
  • 16:37
    rossabaker labeled #6960
  • 16:37
    rossabaker labeled #6960
  • 16:37
    rossabaker opened #6960
  • 16:33
    valencik opened #6959
  • 16:14
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
Rohde Fischer
@rohdef
but wouldn't that result in multiple requests?
Fabio Labella
@SystemFw
you do it inside fetch
those extractors work on the response
Rohde Fischer
@rohdef
ah neat, that makes more sense then :)