Rather than setting a timeout per request, is it possible to set a default across all connections opened within a session?
Any option that can be edited per request can also be set on the Connection instance that you can use to make all your requests.
conn = Faraday.new("https://api.example.com", request: {
open_timeout: 2, # opening a connection
timeout: 5 # waiting for response
})
conn.get(...)
Perfect, thanks!
Since I see very few correct mentions of this elsewhere, the builder version of this in 0.9.2 is this, with the options attribute being the request option defaults:
Faraday::Connection.new('https://api.example.com') do |builder|
builder.options[:open_timeout] = 2
builder.options[:timeout] = 5
builder.adapter Faraday.default_adapter
end
Both examples explain how to set per request, How I can set globally?
@neohunter the example above will set it for each request done from that connection. Faraday doesn't currently support a global setting for all connections, but that shouldn't really be necessary as the number of connections you manage should be just a few (actually, only one in most cases).
Most helpful comment
Since I see very few correct mentions of this elsewhere, the builder version of this in 0.9.2 is this, with the options attribute being the request option defaults: