Git Product home page Git Product logo

Comments (5)

mrkkrp avatar mrkkrp commented on July 24, 2024

Thanks! No those will run sequentially, just like with http-client. You'd need to use something like async to make them run in parallel. For latency you could perhaps use clock to measure how long the entire req business takes, Chris Done has a blog post about this:

http://chrisdone.com/posts/measuring-duration-in-haskell

If you only want to measure time from start of request up to when you get a response you probably could register "end time" in reqBr before you stream the response.

from req.

angerman avatar angerman commented on July 24, 2024

It seems like meshing with async seems to force everthing into IO. Essentially resulting in

runConcurrently $ (,) <$> Concurrently (runReq def (req GET ...))
                      <*> Concurrently (runReq def (req GET ...))

this seems a bit less elegant than I'd like it to be.

Thanks for the point towards Chris Dones post. I'll look into it!

from req.

mrkkrp avatar mrkkrp commented on July 24, 2024

There is also lifted-async, although I'd not recommend using it over stateful monadic stacks as a general practice.

from req.

angerman avatar angerman commented on July 24, 2024

Ohh right. Completely forgot about lifted-async. I'm an idiot, sorry! And yes, state and concurrency almost never play well together :-)

As is, I guess my only request is that the sequential nature of the requests is noted in the documentation, explicitly mentioning that they are not concurrent (to ensure the keyword
is easily found).

Thanks again!

from req.

mrkkrp avatar mrkkrp commented on July 24, 2024

I don't know how they possibly can be concurrent, because they return the (actual) response in a monadic context. That means that I can write:

main = do
  response <- req GET ...
  if response ....
    then req GET ...foo
    else req GET ...bar

Now if there were a possibility of concurrency, I would not be able to write code like this. Just like you cannot write this sort of code with async because the concurrent framework only provides you the power of applicative (concurrency-friendly concept), not monad (imposes sequential execution).

from req.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.