Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    André Diego Piske
    @andrepiske
    @iMacTia Thanks for the explanation. As I said, I just wanted to know the motivation behind it. I thought it would probably be due to lack of contributors.
    John Manoogian III
    @jm3
    :wave:
    anyone have any experience updating old gems dependent on an old version of faraday that's now throwing lots of deprecation errors? I have an old half-finished app I was playing with that uses the wayback (as in archive.org) gem, and I'm a little stuck. I updated the faraday + faraday middleware versions, and now it looks like the next step will be porting some code that uses Faraday::Builder to <whatever the new syntax is>. Are there any reference examples I could take a look at to understand what I might need to change to make this gem work with latest Faraday?
    (wayback's last release that i forked was dependent on faraday 0.9.2)
    Matt
    @iMacTia
    Hey @jm3, welcome to the channel. If the deprecation message comes from Faraday, then we usually also indicate how to fix it. I’m wondering if the ones you see are coming from a ruby/faraday combo instead.
    Feel free to open an issue in the GitHub repo with more details about the warnings you’re seeing and we’ll be happy to have a look
    Apart from that, all versions after 0.9.2 (including the latest 1.0.x) are supposed to be fully backwards-compatible, so you should be able to update to the latest, as far as you use Ruby 2.4+
    Moneer
    @barhum
    Any proper way to rescue a connection error in Faraday if post fails? I am using the following response = Faraday.post('url', converted_hash)
    Matt
    @iMacTia
    @barhum can’t think of any better way than wrapping that into a begin/rescue block. Are you in any particular situation where that might not be the best approach?
    Tim Wisniewski
    @timwis
    Hey, I'm trying to create a "service" (external rest api wrapper) in rails. Does anyone have an example of this? In particular, it requires an API key, so I'd prefer to just initialise it once
    Matt
    @iMacTia
    Hey @timwis, this sounds like the perfect use case for Faraday. There’s no generic guide or way to do it as it depends on how you need to provide the API Key to the server. You can checkout our site (https://lostisland.github.io/faraday/) and particularly how to customise your request, to get started. You’re most probably looking to set a default header on all requests and can do so by passing it to your connection initializer.
    Checkout the section “The Connection Object” at the bottom of this page: https://lostisland.github.io/faraday/usage/
    The example shows you how to set the content-type header for all requests, you can apply the same strategy to set the header for your API key
    Tim Wisniewski
    @timwis
    Thanks. I think I’m just not super familiar with where I’d initialise it in a rails context if it’s used by multiple controllers. Seems redundant to initialise it multiple times with the same api key
    Matt
    @iMacTia
    Of course! maybe the easiest way is to create a class (Client) which initialises the connection, then use a Rails initialiser to store an instance of the client in the Rails.application.config. You’ll then be able to access it from anywhere in your app
    Erik Jacobs
    @thoraxe
    I am trying to use Faraday with webmock but I think I'm having an issue with using a connection object. However I want to use Faraday::Response::RaiseError to simplify handling problems. Is there a way to use Faraday::Response::RaiseError without a connection object?
    bblimke/webmock#894 describes my code and what's going on
    Erik Jacobs
    @thoraxe
    ok i think the connection object is a red herring, because I switched to trying to use excon and had the same issue. I think this is a webmock+sidekiq problem.
    Matt
    @iMacTia
    @thoraxe I hope you managed to fix your issue in the meantime, but if not, then reest assured I used the Faraday-Webmock pair A LOT in the past with no issues. Actually, if you check the Faraday repository you’ll see that Faraday tests are written using WebMock :smiley: !
    If you’re still experiencing issues and believe it’s related to Faraday, please feel free to share an I can have a look
    Erik Jacobs
    @thoraxe
    @iMacTia i ended up staying with excon. At this point I don't recall why I couldn't get Faraday going. I also think there was less complexity in the end writing my tests for Excon, but that's because I couldn't understand how to write my tests for Faraday. Not knocking Faraday.
    Matt
    @iMacTia
    No worries @thoraxe! I’m a believer there’s always a right tool for the right job. Faraday was simply not the right tool for you, it happens!
    Erik Jacobs
    @thoraxe
    ya no hard feelings for sure!
    I'm still using Faraday because IIRC it's used under the covers by the Elasticsearch gems :)
    FLk823
    @ZhaoZijie
    how to get resp cookies?
    Matt
    @iMacTia
    @ZhaoZijie cookies are in response headers (usually Set-Cookie)
    FLk823
    @ZhaoZijie
    yep,can easy like restclient? resp.cookies
    Matt
    @iMacTia
    Top of my head I’m not sure we have that in Faraday, actually!
    But I can check the code later on and confirm/deny
    Agree it would be useful at least
    FLk823
    @ZhaoZijie
    @iMacTia thankyou
    Matt
    @iMacTia
    @ZhaoZijie So unfortunately I checked the code and I can confirm there's no such helper in Faraday at the moment. I guess that's mostly because cookies are not a good practice for server-server communication. That said, I did find a gem called faraday-cookie_jar that implemented cookies forwarding between faraday requests as a middleware.
    if that's not exactly what you need, and you simply need to parse cookies, then that gem uses http-cookie to do that, you can see how that works in the middleware on_complete function: https://github.com/miyagawa/faraday-cookie_jar/blob/master/lib/faraday/cookie_jar.rb
    I hope at least this helps!
    Daniel Martinez Sarta
    @danielmartinezsarta
    Hi all! I have a problem using Faraday with docker, I don't know if docker it's the problem really. I'm calling an API with postman and with the same parameters and body using Faraday i get "execution expired" exception.
    Matt
    @iMacTia
    Hi @danielmartinezsarta , Docker can be quite fussy when it comes to networking. Also, networking changes significantly inside and outside of containers.
    You mentioned Postman, which I'd assume is the application running on your computer, but when you say that you get "execution expired" with Faraday, where is this Ruby code running?
    Is it from inside a container or outside?
    Bobby McDonald
    @BobbyMcWho
    Does Faraday provide a resolved IP on the response object by any chance? I can't find anything in source code, so I'm assuming no, but wanted to confirm
    Bobby McDonald
    @BobbyMcWho
    Looks like Typhoeus (the adapter I'm using ) provides a #primary_ip method, need to see if I can access that without monkey-patching
    Bobby McDonald
    @BobbyMcWho
    Submitted a feature request: lostisland/faraday#1186
    Matt
    @iMacTia
    👍👍
    Daniel Martinez Sarta
    @danielmartinezsarta
    You mentioned Postman, which I'd assume is the application running on your computer, but when you say that you get "execution expired" with Faraday, where is this Ruby code running?
    Hi Matt, thanks for your response, it appears that docker network was the problem, I did a docker system prune and also I changed the way that I was creating the http client to block format and now It is working flawlessly
    Matt
    @iMacTia
    That’s great to hear @danielmartinezsarta 🙌
    jmarsh24
    @jmarsh24
    hellooooo
    Matt
    @iMacTia
    👋👋
    Danilo Domínguez Pérez
    @danilo04
    Hi all, I am trying to test faraday's retries but I cannot find any documentation about it. I tried the Faraday stubs but didn't work.
    Is there any way to test the retries in Faraday, like making several stubs for the same endpoint, so they can be returned on each retry
    Matt
    @iMacTia
    Hi @danilo04, it really depends on the trigger for the retry (timeout or response status code), but I usually use the Faraday Test Adapter or a solution like Webmock. You can also check how we test it here
    Danilo Domínguez Pérez
    @danilo04
    HI @iMacTia, I think I can control the tests with the callback. Works for me. Thanks!!