ApiAdresse: add timeout

This commit is contained in:
simon lehericey 2019-04-23 14:31:01 +02:00
parent 070ef13ea5
commit 14c3686969

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