Skip to content
Snippets Groups Projects
Commit c4256232 authored by Alex Reisner's avatar Alex Reisner
Browse files

Add ability to configure timeout duration.

parent 6be7d6b5
No related branches found
No related tags found
No related merge requests found
......@@ -97,8 +97,11 @@ If your model has +address+, +city+, +state+, and +country+ attributes you might
[address, city, state, country].compact.join(', ')
end
Please see the code (<tt>lib/geocoder/active_record.rb</tt>) for more methods and detailed information about arguments (eg, working with kilometers).
Please see the code for more methods and detailed information about arguments (eg, working with kilometers).
You can also set the timeout used for connections to Google's geocoding service. The default is 3 seconds, but if you want to set it to 5 you could put the following in an initializer:
Geocoder::Configuration.timeout = 5
== Reverse Geocoding
......
require "geocoder/configuration"
require "geocoder/calculations"
require "geocoder/lookup"
require "geocoder/result"
......
module Geocoder
class Configuration
cattr_accessor :timeout
end
end
Geocoder::Configuration.timeout = 3
......@@ -61,7 +61,7 @@ module Geocoder
url = query_url(query, reverse)
begin
resp = nil
timeout(3) do
timeout(Geocoder::Configuration.timeout) do
Net::HTTP.get_response(URI.parse(url)).body
end
rescue SocketError, TimeoutError
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment