Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What do you want in Faraday 1.0? #202

Closed
technoweenie opened this issue Oct 20, 2012 · 15 comments
Closed

What do you want in Faraday 1.0? #202

technoweenie opened this issue Oct 20, 2012 · 15 comments

Comments

@technoweenie
Copy link
Member

@eric
Copy link
Contributor

eric commented Oct 20, 2012

👍

@mislav
Copy link
Contributor

mislav commented Oct 22, 2012

I think separate request/response stacks are interesting and worth exploring. I would definitely start with a subset of that idea and just extract adapters out of this whole things as endpoints not middleware (#47) which also makes them easily swappable (common pitfall), ensures that they don't end up elsewhere that is not at the end of middleware stack (common pitfall) and makes some implementation code simpler. I'm going to do this soon in a backwards-compatible manner.

@technoweenie
Copy link
Member Author

I took a completely different approach and broke away from Rack completely: #207

It slaughters backwards compatibility, but I really like how simpler the middleware (now called callbacks) and adapters are.

@pezra
Copy link

pezra commented Oct 31, 2012

I don't know if faraday is the layer for this but i'd like a futures/promise based interface for making http requests. ie, i call conn.get { ... } and i get a response object back before the request has actually completed. The request would take place in the background and the response would be populated once it was complete. If i accessed anything on the response object it would block until the request was complete and then do whatever.

This would make it fairly easy to make several http requests at the same time. All that would be required is to just make one call right after another. The gory details are hidden so that clients that don't need/want concurrent requests could carry on as if the requests where made synchronously.

@technoweenie
Copy link
Member Author

@pezra: That's currently possible with Typhoeus, and maybe EM? You need to make a batch of requests with the same parallel manager (which is the Hydra object in Typhoeus 0.4, and something else in Typhoeus 0.5).

I'm really hoping that I can get it to work with the new builder stuff. It's one of my required features before I merge that branch into master.

@pezra
Copy link

pezra commented Oct 31, 2012

Typhoeus and EM handle concurrency quite differently (and sort of awkwardly, imo). In Typhoeus, if i understand it correctly, you must define all the requests you want to run in parallel in a single block and none of the responses are available until all have completed. This introduces unnecessary latency for short requests in a batch. It also requires that you reorganize your code in order to use this feature. With EM you need to get involved in the whole async io quagmire to accomplish this. :)

The goal of a futures based approach is that it would provide improved latency for http requests in a transparent and comfortably OO way. In the best case doing exactly what is done now goes a lot faster and in the worst case the performance is unchanged.

This could be implemented above the faraday level but i thought i'd throw it out there to see if it has legs.

@ismell
Copy link

ismell commented Nov 5, 2012

I would like to see some support for Digest Auth: https://github.com/technoweenie/faraday/issues/109 :)

@hanshasselberg
Copy link

@pezra @technoweenie You still do async requests with Typhoeus::Hydra with Typhoeus version 0.5.
@pezra Responses are available through callbacks as soon as they arrive:

request = Typhoeus::Request.new("www.exmple.com")
request.on_complete{ |response| p "completed" }

hydra = Typhoeus::Hydra.new
hydra.queue(request)
hydra.run
#=> "completed"

That way you don't have to wait until the Hydra#run returns.

@ghost ghost mentioned this issue Jan 10, 2013
@oriolgual
Copy link

@ismell I've been working on a DigestAuth middleware (here and here). I still need to add documentation but right now it works (at least with NetHTTP). I was thinking of sending a PR with it, so feedback is appreciated :)

@ismell
Copy link

ismell commented Feb 22, 2013

I vote for persistent connections? Looking at the net-http-persistent adapter it seems to recreate create the connection for every request.

@mislav
Copy link
Contributor

mislav commented Feb 23, 2013

@ismell It may appear so, but it doesn't. All instances of NHPersistent use the same connection pool.

@ismell
Copy link

ismell commented Mar 1, 2013

Oh well good to know :) Thanks!

@marshall-lee
Copy link

Maybe convenient method for constructing a connection pool using connection_pool gem?

@mnussbaumer
Copy link

A in-depth tutorial!

@iMacTia
Copy link
Member

iMacTia commented Nov 7, 2017

Closing in favour of #620

@iMacTia iMacTia closed this as completed Nov 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants