#278 - Add option for connection timeouts

This commit is contained in:
Steve Bazyl 2015-10-02 13:42:47 -07:00
parent 859fd8503f
commit ed40d7b750
2 changed files with 6 additions and 1 deletions

View File

@ -292,6 +292,7 @@ module Google
def new_client
client = Hurley::Client.new
client.request_options.timeout = request_options.timeout_sec
client.request_options.open_timeout = request_options.open_timeout_sec
client.request_options.proxy = client_options.proxy_url
client.request_options.query_class = Hurley::Query::Flat
client.ssl_options.ca_file = File.join(Google::Apis::ROOT, 'lib', 'cacerts.pem')

View File

@ -24,7 +24,8 @@ module Google
:authorization,
:retries,
:header,
:timeout_sec)
:timeout_sec,
:open_timeout_sec)
# General client options
class ClientOptions
@ -50,6 +51,8 @@ module Google
# @return [Fixnum] Number of times to retry requests on server error
# @!attribute [rw] timeout_sec
# @return [Fixnum] How long, in seconds, before requests time out
# @!attribute [rw] open_timeout_sec
# @return [Fixnum] How long, in seconds, before failed connections time out
# @!attribute [rw] header
# @return [Hash<String,String] Additional HTTP headers to include in requests
@ -75,5 +78,6 @@ module Google
ClientOptions.default.application_version = '0.0.0'
RequestOptions.default.retries = 0
RequestOptions.default.open_timeout_sec = 20
end
end