Class: Google::Gax::CallSettings

Inherits:
Object
  • Object
show all
Defined in:
lib/google/gax.rb

Overview

Encapsulates the call settings for an ApiCallable

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(timeout: 30, retry_options: nil, page_descriptor: nil, bundler: nil, bundle_descriptor: nil) ⇒ CallSettings

Returns a new instance of CallSettings.

Parameters:

  • timeout (Numeric) (defaults to: 30)

    The client-side timeout for API calls. This parameter is ignored for retrying calls.

  • retry_options (RetryOptions) (defaults to: nil)

    The configuration for retrying upon transient error. If set to None, this call will not retry.

  • page_descriptor (PageDescriptor) (defaults to: nil)

    indicates the structure of page streaming to be performed. If set to None, page streaming is not performed.

  • bundler (defaults to: nil)

    orchestrates bundling. If None, bundling is not performed.

  • bundle_descriptor (BundleDescriptor) (defaults to: nil)

    indicates the structure of the bundle. If None, bundling is not performed.



63
64
65
66
67
68
69
70
71
# File 'lib/google/gax.rb', line 63

def initialize(
    timeout: 30, retry_options: nil, page_descriptor: nil,
    bundler: nil, bundle_descriptor: nil)
  @timeout = timeout
  @retry_options = retry_options
  @page_descriptor = page_descriptor
  @bundler = bundler
  @bundle_descriptor = bundle_descriptor
end

Instance Attribute Details

#bundle_descriptorBundleDescriptor (readonly)

Returns:



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/google/gax.rb', line 48

class CallSettings
  attr_reader :timeout, :retry_options, :page_descriptor, :bundler,
              :bundle_descriptor

  # @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 None, this call will not retry.
  # @param page_descriptor [PageDescriptor] indicates the structure of page
  #   streaming to be performed. If set to None, page streaming is not
  #   performed.
  # @param bundler orchestrates bundling. If None, bundling is not
  #   performed.
  # @param bundle_descriptor [BundleDescriptor] indicates the structure of
  #   the bundle. If None, bundling is not performed.
  def initialize(
      timeout: 30, retry_options: nil, page_descriptor: nil,
      bundler: nil, bundle_descriptor: nil)
    @timeout = timeout
    @retry_options = retry_options
    @page_descriptor = page_descriptor
    @bundler = bundler
    @bundle_descriptor = bundle_descriptor
  end

  # @return true when it has retry codes.
  def retry_codes?
    @retry_options && @retry_options.retry_codes
  end

  # @return true when it has valid bundler configuration.
  def bundler?
    @bundler && @bundle_descriptor
  end

  # 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.
  def merge(options)
    unless options
      return CallSettings.new(
        timeout: @timeout,
        retry_options: @retry_options,
        page_descriptor: @page_descriptor,
        bundler: @bundler,
        bundle_descriptor: @bundle_descriptor)
    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_descriptor = @page_descriptor if options.is_page_streaming

    CallSettings.new(
      timeout: timeout,
      retry_options: retry_options,
      page_descriptor: page_descriptor,
      bundler: @bundler,
      bundle_descriptor: @bundle_descriptor)
  end
end

#bundlerObject (readonly)

Returns the value of attribute bundler.



49
50
51
# File 'lib/google/gax.rb', line 49

def bundler
  @bundler
end

#page_descriptorPageDescriptor (readonly)

Returns:



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/google/gax.rb', line 48

class CallSettings
  attr_reader :timeout, :retry_options, :page_descriptor, :bundler,
              :bundle_descriptor

  # @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 None, this call will not retry.
  # @param page_descriptor [PageDescriptor] indicates the structure of page
  #   streaming to be performed. If set to None, page streaming is not
  #   performed.
  # @param bundler orchestrates bundling. If None, bundling is not
  #   performed.
  # @param bundle_descriptor [BundleDescriptor] indicates the structure of
  #   the bundle. If None, bundling is not performed.
  def initialize(
      timeout: 30, retry_options: nil, page_descriptor: nil,
      bundler: nil, bundle_descriptor: nil)
    @timeout = timeout
    @retry_options = retry_options
    @page_descriptor = page_descriptor
    @bundler = bundler
    @bundle_descriptor = bundle_descriptor
  end

  # @return true when it has retry codes.
  def retry_codes?
    @retry_options && @retry_options.retry_codes
  end

  # @return true when it has valid bundler configuration.
  def bundler?
    @bundler && @bundle_descriptor
  end

  # 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.
  def merge(options)
    unless options
      return CallSettings.new(
        timeout: @timeout,
        retry_options: @retry_options,
        page_descriptor: @page_descriptor,
        bundler: @bundler,
        bundle_descriptor: @bundle_descriptor)
    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_descriptor = @page_descriptor if options.is_page_streaming

    CallSettings.new(
      timeout: timeout,
      retry_options: retry_options,
      page_descriptor: page_descriptor,
      bundler: @bundler,
      bundle_descriptor: @bundle_descriptor)
  end
end

#retry_optionsRetryOptions (readonly)

Returns:



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/google/gax.rb', line 48

class CallSettings
  attr_reader :timeout, :retry_options, :page_descriptor, :bundler,
              :bundle_descriptor

  # @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 None, this call will not retry.
  # @param page_descriptor [PageDescriptor] indicates the structure of page
  #   streaming to be performed. If set to None, page streaming is not
  #   performed.
  # @param bundler orchestrates bundling. If None, bundling is not
  #   performed.
  # @param bundle_descriptor [BundleDescriptor] indicates the structure of
  #   the bundle. If None, bundling is not performed.
  def initialize(
      timeout: 30, retry_options: nil, page_descriptor: nil,
      bundler: nil, bundle_descriptor: nil)
    @timeout = timeout
    @retry_options = retry_options
    @page_descriptor = page_descriptor
    @bundler = bundler
    @bundle_descriptor = bundle_descriptor
  end

  # @return true when it has retry codes.
  def retry_codes?
    @retry_options && @retry_options.retry_codes
  end

  # @return true when it has valid bundler configuration.
  def bundler?
    @bundler && @bundle_descriptor
  end

  # 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.
  def merge(options)
    unless options
      return CallSettings.new(
        timeout: @timeout,
        retry_options: @retry_options,
        page_descriptor: @page_descriptor,
        bundler: @bundler,
        bundle_descriptor: @bundle_descriptor)
    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_descriptor = @page_descriptor if options.is_page_streaming

    CallSettings.new(
      timeout: timeout,
      retry_options: retry_options,
      page_descriptor: page_descriptor,
      bundler: @bundler,
      bundle_descriptor: @bundle_descriptor)
  end
end

#timeoutNumeric (readonly)

Returns:

  • (Numeric)


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/google/gax.rb', line 48

class CallSettings
  attr_reader :timeout, :retry_options, :page_descriptor, :bundler,
              :bundle_descriptor

  # @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 None, this call will not retry.
  # @param page_descriptor [PageDescriptor] indicates the structure of page
  #   streaming to be performed. If set to None, page streaming is not
  #   performed.
  # @param bundler orchestrates bundling. If None, bundling is not
  #   performed.
  # @param bundle_descriptor [BundleDescriptor] indicates the structure of
  #   the bundle. If None, bundling is not performed.
  def initialize(
      timeout: 30, retry_options: nil, page_descriptor: nil,
      bundler: nil, bundle_descriptor: nil)
    @timeout = timeout
    @retry_options = retry_options
    @page_descriptor = page_descriptor
    @bundler = bundler
    @bundle_descriptor = bundle_descriptor
  end

  # @return true when it has retry codes.
  def retry_codes?
    @retry_options && @retry_options.retry_codes
  end

  # @return true when it has valid bundler configuration.
  def bundler?
    @bundler && @bundle_descriptor
  end

  # 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.
  def merge(options)
    unless options
      return CallSettings.new(
        timeout: @timeout,
        retry_options: @retry_options,
        page_descriptor: @page_descriptor,
        bundler: @bundler,
        bundle_descriptor: @bundle_descriptor)
    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_descriptor = @page_descriptor if options.is_page_streaming

    CallSettings.new(
      timeout: timeout,
      retry_options: retry_options,
      page_descriptor: page_descriptor,
      bundler: @bundler,
      bundle_descriptor: @bundle_descriptor)
  end
end

Instance Method Details

#bundler?Boolean

Returns true when it has valid bundler configuration.

Returns:

  • (Boolean)

    true when it has valid bundler configuration.



79
80
81
# File 'lib/google/gax.rb', line 79

def bundler?
  @bundler && @bundle_descriptor
end

#merge(options) ⇒ Object

Creates a new CallSetting instance which is based on this but merged settings from options.

Parameters:

  • options (CallOptions, nil)

    The overriding call settings.

Returns:

  • a new merged call settings.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/google/gax.rb', line 87

def merge(options)
  unless options
    return CallSettings.new(
      timeout: @timeout,
      retry_options: @retry_options,
      page_descriptor: @page_descriptor,
      bundler: @bundler,
      bundle_descriptor: @bundle_descriptor)
  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_descriptor = @page_descriptor if options.is_page_streaming

  CallSettings.new(
    timeout: timeout,
    retry_options: retry_options,
    page_descriptor: page_descriptor,
    bundler: @bundler,
    bundle_descriptor: @bundle_descriptor)
end

#retry_codes?Boolean

Returns true when it has retry codes.

Returns:

  • (Boolean)

    true when it has retry codes.



74
75
76
# File 'lib/google/gax.rb', line 74

def retry_codes?
  @retry_options && @retry_options.retry_codes
end