Merge pull request #3808 from betagouv/add_timeout_to_address_api

ApiAdresse: add timeout
This commit is contained in:
Paul Chavard 2019-04-23 14:48:54 +02:00 committed by GitHub
commit d0d8eb34c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,7 +2,10 @@ class ApiAdresse::API
def self.call(address, limit = 1) def self.call(address, limit = 1)
search_url = [API_ADRESSE_URL, "search"].join("/") search_url = [API_ADRESSE_URL, "search"].join("/")
RestClient.get(search_url, params: { q: address, limit: limit }) RestClient::Request.execute(method: :get,
url: search_url,
timeout: 5,
headers: { params: { q: address, limit: limit } })
rescue RestClient::ServiceUnavailable rescue RestClient::ServiceUnavailable
nil nil
end end