Is it safe to reuse Faraday connection objects, or is it better to recreate them every time?
def connection
@connection ||= Faraday.new('http://example.com') do |conn|
conn.request :url_encoded
# more configuration
end
end
Is it safe to reuse Faraday connection objects, or is it better to recreate them every time?
def connection
@connection ||= Faraday.new('http://example.com') do |conn|
conn.request :url_encoded
# more configuration
end
end
connection.get .post and all other methods duplicates params etc here.
It means each request shares nothing with each other and the parent Connection object.
It's safe to reuse.