Comments (5)
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.
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.
There is also lifted-async
, although I'd not recommend using it over stateful monadic stacks as a general practice.
from req.
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.
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)
- Make Req an instance of MonadUnliftIO HOT 2
- Cannot perform a request with url containing braces HOT 7
- Hard to pass Link header URIs back into req HOT 5
- When req fails with a StatusCodeException the body is truncated HOT 4
- Get access to the Request HOT 5
- Add `MonadMask` instance for `Req`?
- ConnectionTimeout with "req" even though "curl" and browser work just fine HOT 1
- Set a retrying limit by default for request timeouts HOT 2
- not installable on ghc 9.0.1 due to reliance on base <4.15 HOT 3
- Support retry 0.9 HOT 1
- How can I retrieve the exact URL with query parameters? Possible limitation? HOT 6
- Interface with ToForm and FromForm HOT 2
- Support for GHC 9.2 HOT 2
- Not compatible with transformers-0.6 HOT 1
- Couldn't find a way to call odata services HOT 1
- No way to force encoding of a segment HOT 1
- Couldn't match expected type ‘NC.TLSSettings’ HOT 1
- How can I retry the request even if it errors out? HOT 2
- unexpected program termination HOT 2
- Inspecting Request Created by `req` Function HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from req.