lib/google/cloud/storage.rb in google-cloud-storage-1.36.2 vs lib/google/cloud/storage.rb in google-cloud-storage-1.37.0
- old
+ new
@@ -53,10 +53,15 @@
# The default scope is:
#
# * `https://www.googleapis.com/auth/devstorage.full_control`
# @param [Integer] retries Number of times to retry requests on server
# error. The default value is `3`. Optional.
+ # @param [Integer] max_elapsed_time Total time in seconds that requests are allowed to keep being retried.
+ # @param [Float] base_interval The initial interval in seconds between tries.
+ # @param [Integer] max_interval The maximum interval in seconds that any individual retry can reach.
+ # @param [Integer] multiplier Each successive interval grows by this factor. A multipler of 1.5 means the next
+ # interval will be 1.5x the current interval.
# @param [Integer] timeout (default timeout) The max duration, in seconds, to wait before timing out. Optional.
# If left blank, the wait will be at most the time permitted by the underlying HTTP/RPC protocol.
# @param [Integer] open_timeout How long, in seconds, before failed connections time out. Optional.
# @param [Integer] read_timeout How long, in seconds, before requests time out. Optional.
# @param [Integer] send_timeout How long, in seconds, before receiving response from server times out. Optional.
@@ -77,22 +82,28 @@
# )
#
# bucket = storage.bucket "my-bucket"
# file = bucket.file "path/to/my-file.ext"
#
- # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
def self.new project_id: nil, credentials: nil, scope: nil, retries: nil,
timeout: nil, open_timeout: nil, read_timeout: nil,
- send_timeout: nil, endpoint: nil, project: nil, keyfile: nil
- scope ||= configure.scope
- retries ||= configure.retries
- timeout ||= configure.timeout
- open_timeout ||= (configure.open_timeout || timeout)
- read_timeout ||= (configure.read_timeout || timeout)
- send_timeout ||= (configure.send_timeout || timeout)
- endpoint ||= configure.endpoint
- credentials ||= (keyfile || default_credentials(scope: scope))
+ send_timeout: nil, endpoint: nil, project: nil, keyfile: nil,
+ max_elapsed_time: nil, base_interval: nil, max_interval: nil,
+ multiplier: nil
+ scope ||= configure.scope
+ retries ||= configure.retries
+ timeout ||= configure.timeout
+ open_timeout ||= (configure.open_timeout || timeout)
+ read_timeout ||= (configure.read_timeout || timeout)
+ send_timeout ||= (configure.send_timeout || timeout)
+ endpoint ||= configure.endpoint
+ credentials ||= (keyfile || default_credentials(scope: scope))
+ max_elapsed_time ||= configure.max_elapsed_time
+ base_interval ||= configure.base_interval
+ max_interval ||= configure.max_interval
+ multiplier ||= configure.multiplier
unless credentials.is_a? Google::Auth::Credentials
credentials = Storage::Credentials.new credentials, scope: scope
end
@@ -102,22 +113,29 @@
Storage::Project.new(
Storage::Service.new(
project_id, credentials,
retries: retries, timeout: timeout, open_timeout: open_timeout,
read_timeout: read_timeout, send_timeout: send_timeout,
- host: endpoint, quota_project: configure.quota_project
+ host: endpoint, quota_project: configure.quota_project,
+ max_elapsed_time: max_elapsed_time, base_interval: base_interval,
+ max_interval: max_interval, multiplier: multiplier
)
)
end
- # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
##
# Creates an unauthenticated, anonymous client for retrieving public data
# from the Storage service. Each call creates a new connection.
#
# @param [Integer] retries Number of times to retry requests on server
# error. The default value is `3`. Optional.
+ # @param [Integer] max_elapsed_time Total time in seconds that requests are allowed to keep being retried.
+ # @param [Float] base_interval The initial interval in seconds between tries.
+ # @param [Integer] max_interval The maximum interval in seconds that any individual retry can reach.
+ # @param [Integer] multiplier Each successive interval grows by this factor. A multipler of 1.5 means the next
+ # interval will be 1.5x the current interval.
# @param [Integer] timeout (default timeout) The max duration, in seconds, to wait before timing out. Optional.
# If left blank, the wait will be at most the time permitted by the underlying HTTP/RPC protocol.
# @param [Integer] open_timeout How long, in seconds, before failed connections time out. Optional.
# @param [Integer] read_timeout How long, in seconds, before requests time out. Optional.
# @param [Integer] send_timeout How long, in seconds, before receiving response from server times out. Optional.
@@ -137,18 +155,22 @@
# downloaded = file.download
# downloaded.rewind
# downloaded.read #=> "Hello world!"
#
def self.anonymous retries: nil, timeout: nil, open_timeout: nil,
- read_timeout: nil, send_timeout: nil, endpoint: nil
+ read_timeout: nil, send_timeout: nil, endpoint: nil,
+ max_elapsed_time: nil, base_interval: nil, max_interval: nil,
+ multiplier: nil
open_timeout ||= timeout
read_timeout ||= timeout
send_timeout ||= timeout
Storage::Project.new(
Storage::Service.new(
nil, nil, retries: retries, timeout: timeout, open_timeout: open_timeout,
- read_timeout: read_timeout, send_timeout: send_timeout, host: endpoint
+ read_timeout: read_timeout, send_timeout: send_timeout, host: endpoint,
+ max_elapsed_time: max_elapsed_time, base_interval: base_interval,
+ max_interval: max_interval, multiplier: multiplier
)
)
end
##
@@ -166,9 +188,16 @@
# to use the default endpoint.
# * `scope` - (String, Array<String>) The OAuth 2.0 scopes controlling
# the set of resources and operations that the connection can access.
# * `retries` - (Integer) Number of times to retry requests on server
# error.
+ # * `max_elapsed_time` - (Integer) Total time in seconds that requests
+ # are allowed to keep being retried.
+ # * `base_interval` - (Float) The initial interval in seconds between tries.
+ # * `max_interval` - (Integer) The maximum interval in seconds that any
+ # individual retry can reach.
+ # * `multiplier` - (Integer) Each successive interval grows by this factor.
+ # A multipler of 1.5 means the next interval will be 1.5x the current interval.
# * `timeout` - (Integer) (default timeout) The max duration, in seconds, to wait before timing out.
# If left blank, the wait will be at most the time permitted by the underlying HTTP/RPC protocol.
# * `open_timeout` - (Integer) How long, in seconds, before failed connections time out.
# * `read_timeout` - (Integer) How long, in seconds, before requests time out.
# * `send_timeout` - (Integer) How long, in seconds, before receiving response from server times out.