rspotify icon indicating copy to clipboard operation
rspotify copied to clipboard

Possibly switch the HTTP client to Faraday?

Open jeregrine opened this issue 10 years ago • 4 comments

Would you be willing to accept a PR to swap restclient for Faraday? It would be crazy useful to have a configurable HTTP client.

Let me know and we can put some engineering time into this right away.

jeregrine avatar Dec 22 '15 15:12 jeregrine

@jeregrine could you clarify what exactly you want to achieve with it? RestClient is more lightweight than Faraday so I'd only opt for the latter if really needed.

guilhermesad avatar Dec 23 '15 19:12 guilhermesad

@guilhermesad I'm not sure I've seen anything that says "RestClient is more lightweight" than any other client. I DO know that I can choose my own HTTP client library and use the same one for my project and then do neat things like metrics, pooling connections and swap out different adapters with Faraday. (ex using a native Java client with jruby)

I will prolly end up doing this anyways and maintaining my own fork. I just wanted to test the waters and see if you'd like this.

jeregrine avatar Dec 29 '15 18:12 jeregrine

@jeregrine seems good, I'm in for that :+1: Regarding RestClient being more lightweight, although its package is lighter it seems to be significantly slower:

n = 100

Benchmark.bm do |x|
  x.report('RestClient:') { for i in 1..n; RestClient.get 'http://sushi.com/nigiri/sake.json'; end }
  x.report('Faraday:') { for i in 1..n; Faraday.get 'http://sushi.com/nigiri/sake.json'; end }
end

                 user     system      total        real
RestClient:  3.680000   0.170000   3.850000 (107.588036)
Faraday:     0.240000   0.050000   0.290000 ( 44.608382)

So I'm down for switching to Faraday

guilhermesad avatar Jan 05 '16 13:01 guilhermesad

+1 on this, that would be great!

megeek avatar May 31 '17 20:05 megeek