Mangopay / mangopay2-ruby-sdk

Ruby Gem for MANGOPAY
https://rubygems.org/gems/mangopay
MIT License
42 stars 38 forks source link

Using Faraday ? #25

Closed jlecour closed 9 years ago

jlecour commented 9 years ago

Hi,

I've started working on a MangoPay integration for a (kind of) market place.

I see that API requests are using Net::HTTP. and the MangoPay.request has multiple responsibilities. It doesn't make MangoPay easy to extend and customize.

For example, I'd like to use another HTTP adapter (like net-http_persistent or typhoeus) and add some instrumentation around the requests.

For this kind of customization, I usually use Faraday which lets me change the adapter and add some middleware, very easily. Exposing Faraday outside of MangoPay is not hard too. You can look at how Elasticsearch does this :

All this is just a thought, a direction that seems to be a good idea (in theory, but verified in practice too). What do you think about it?

Thanks for maintaining a Ruby "SDK", I appreciate not having to do this myself :wink:

javiercr commented 9 years ago

@jlecour we're using http_logger gem to add instrumentation to MangoPay requests (you don't need Faraday for this). Definitely recommended.

jlecour commented 9 years ago

@javiercr http_logger seems nice, but it's just a tiny part of the solution.

For example, with Faraday, I use a middleware that emits an ActiveSupport::Notification with a payload that contains all the request and the response details (plus duration, …). A subscriber then pushes that in Elasticsearch and I have a Kibana dashboard to monitor how third party APIs perform over time (with detailed http status, body, …). It seems much more powerful than "just" a text log in development.

javiercr commented 9 years ago

@jlecour I agree that gives you more control. Let's see if the guys at MangoPay decide to give a try to that approach, meanwhile http_logger can save you from some headaches.

hobailey commented 9 years ago

Hi to you both, Thanks for your feedback - we'll look into this and I'll keep you updated via this thread which I'll leave open for now.

hobailey commented 9 years ago

Hello again, Having review this internally, we've decided not to add support for Faraday at this stage. It's something I've noted and we will definitly review again in the future, but in the mean time we've decided to focus on other projects. If you now of other developers interested by this, please ask them to subscribe to this thread and I'll update you all again in the future.