class Google::Gax::CallSettings

Encapsulates the call settings for an ApiCallable @!attribute [r] timeout

@return [Numeric]

@!attribute [r] retry_options

@return [RetryOptions]

@!attribute [r] page_descriptor

@return [PageDescriptor]

@!attribute [r] page_token

@return [Object]

@!attribute [r] bundle_descriptor

@return [BundleDescriptor]

@!attribute [r] metadata

@return [Hash]

Attributes

bundle_descriptor[R]
bundler[R]
errors[R]
metadata[R]
page_descriptor[R]
page_token[R]
retry_options[R]
timeout[R]

Public Class Methods

new(timeout: 30, retry_options: nil, page_descriptor: nil, page_token: nil, bundler: nil, bundle_descriptor: nil, metadata: {}, kwargs: {}, errors: []) click to toggle source

@param timeout [Numeric] The client-side timeout for API calls. This

parameter is ignored for retrying calls.

@param retry_options [RetryOptions] The configuration for retrying upon

transient error. If set to nil, this call will not retry.

@param page_descriptor [PageDescriptor] indicates the structure of page

streaming to be performed. If set to nil, page streaming is not
performed.

@param page_token [Object] determines the page token used in the

page streaming request. If there is no page_descriptor, this has no
meaning.

@param bundler orchestrates bundling. If nil, bundling is not

performed.

@param bundle_descriptor [BundleDescriptor] indicates the structure of

the bundle. If nil, bundling is not performed.

@param metadata [Hash] the request header params. @param kwargs [Hash]

Deprecated, if set this will be merged with the metadata field.

@param errors [Array<Exception>]

Configures the exceptions to wrap with GaxError.
# File lib/google/gax/settings.rb, line 70
def initialize(timeout: 30, retry_options: nil, page_descriptor: nil,
               page_token: nil, bundler: nil, bundle_descriptor: nil,
               metadata: {}, kwargs: {}, errors: [])
  @timeout = timeout
  @retry_options = retry_options
  @page_descriptor = page_descriptor
  @page_token = page_token
  @bundler = bundler
  @bundle_descriptor = bundle_descriptor
  @metadata = metadata
  @metadata.merge!(kwargs) if kwargs && metadata
  @errors = errors
end

Public Instance Methods

bundler?() click to toggle source

@return true when it has valid bundler configuration.

# File lib/google/gax/settings.rb, line 92
def bundler?
  @bundler && @bundle_descriptor
end
merge(options) click to toggle source

Creates a new CallSetting instance which is based on this but merged settings from options. @param options [CallOptions, nil] The overriding call settings. @return a new merged call settings.

# File lib/google/gax/settings.rb, line 100
def merge(options)
  unless options
    return CallSettings.new(timeout: @timeout,
                            retry_options: @retry_options,
                            page_descriptor: @page_descriptor,
                            page_token: @page_token,
                            bundler: @bundler,
                            bundle_descriptor: @bundle_descriptor,
                            metadata: @metadata,
                            errors: @errors)
  end

  timeout = if options.timeout == :OPTION_INHERIT
              @timeout
            else
              options.timeout
            end
  retry_options = if options.retry_options == :OPTION_INHERIT
                    @retry_options
                  else
                    options.retry_options
                  end
  page_token = if options.page_token == :OPTION_INHERIT
                 @page_token
               else
                 options.page_token
               end

  metadata = @metadata || {}
  metadata = metadata.dup
  metadata.update(options.metadata) if options.metadata != :OPTION_INHERIT

  CallSettings.new(timeout: timeout,
                   retry_options: retry_options,
                   page_descriptor: @page_descriptor,
                   page_token: page_token,
                   bundler: @bundler,
                   bundle_descriptor: @bundle_descriptor,
                   metadata: metadata,
                   errors: @errors)
end
retry_codes?() click to toggle source

@return true when it has retry codes.

# File lib/google/gax/settings.rb, line 85
def retry_codes?
  @retry_options &&
    @retry_options.retry_codes &&
    @retry_options.retry_codes.any?
end