If positional argument error is provided, the retriable logic uses
retry_codes. Otherwise, timeout is used.
Returns
(Boolean) — Whether the delay was executed.
#perform_delay!
defperform_delay!()->Boolean
Perform delay.
Returns
(Boolean) — Whether the delay was executed.
#perform_delay_count
defperform_delay_count()->Integer
Current number of times the delay has been performed
Returns
(Integer)
#retry_codes
defretry_codes()->Array<Integer>
Returns
(Array<Integer>) — List of retry codes.
#start!
defstart!(mock_delay:false)
Start tracking the deadline and delay by initializing those values.
This is normally done when the object is constructed, but it can be
done explicitly in order to reinitialize the state in case this
retry policy was created in the past or is being reused.
Parameter
mock_delay (boolean, Proc) (defaults to: false) — if truthy, delays are "mocked",
meaning they do not actually take time, but are measured as if they
did, which is useful for tests. If set to a Proc, it will be called
whenever a delay would happen, and passed the delay in seconds,
also useful for testing.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# gapic-common - Class Gapic::Common::RetryPolicy (v1.1.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.1.0 (latest)](/ruby/docs/reference/gapic-common/latest/Gapic-Common-RetryPolicy)\n- [1.0.1](/ruby/docs/reference/gapic-common/1.0.1/Gapic-Common-RetryPolicy)\n- [0.26.0](/ruby/docs/reference/gapic-common/0.26.0/Gapic-Common-RetryPolicy)\n- [0.25.0](/ruby/docs/reference/gapic-common/0.25.0/Gapic-Common-RetryPolicy)\n- [0.24.0](/ruby/docs/reference/gapic-common/0.24.0/Gapic-Common-RetryPolicy) \nReference documentation and code samples for the gapic-common class Gapic::Common::RetryPolicy.\n\nGapic Common retry policy base class. \n\nInherits\n--------\n\n- Object\n\nMethods\n-------\n\n### #call\n\n def call(error = nil) -\u003e Boolean\n\n**Aliases**\n\n- [#perform_delay](./Gapic-Common-RetryPolicy#Gapic__Common__RetryPolicy_perform_delay_instance_) \nPerform delay if and only if retriable.\n\n\n\u003cbr /\u003e\n\nIf positional argument `error` is provided, the retriable logic uses\n`retry_codes`. Otherwise, `timeout` is used. \n**Returns**\n\n- (Boolean) --- Whether the delay was executed.\n\n### #delay\n\n def delay() -\u003e Numeric\n\nCurrent delay value in seconds. \n**Returns**\n\n- (Numeric) --- Time delay in seconds.\n\n### #dup\n\n def dup() -\u003e RetryPolicy\n\nReturns a duplicate in a non-executing state, i.e. with the deadline\nand current delay reset. \n**Returns**\n\n- ([RetryPolicy](./Gapic-Common-RetryPolicy))\n\n### #initial_delay\n\n def initial_delay() -\u003e Numeric\n\n**Returns**\n\n- (Numeric) --- Initial delay in seconds.\n\n### #initialize\n\n def initialize(initial_delay: nil, max_delay: nil, multiplier: nil, retry_codes: nil, timeout: nil) -\u003e RetryPolicy\n\nCreate new Gapic::Common::RetryPolicy instance. \n**Parameters**\n\n- **initial_delay** (Numeric) *(defaults to: nil)* --- Initial delay in seconds.\n- **max_delay** (Numeric) *(defaults to: nil)* --- Maximum delay in seconds.\n- **multiplier** (Numeric) *(defaults to: nil)* --- The delay scaling factor for each subsequent retry attempt.\n- **retry_codes** (Array\\\u003cString\\|Integer\\\u003e) *(defaults to: nil)* --- List of retry codes.\n- **timeout** (Numeric) *(defaults to: nil)* --- Timeout threshold value in seconds. \n**Returns**\n\n- ([RetryPolicy](./Gapic-Common-RetryPolicy)) --- a new instance of RetryPolicy\n\n### #max_delay\n\n def max_delay() -\u003e Numeric\n\n**Returns**\n\n- (Numeric) --- Maximum delay in seconds.\n\n### #multiplier\n\n def multiplier() -\u003e Numeric\n\n**Returns**\n\n- (Numeric) --- The delay scaling factor for each subsequent retry attempt.\n\n### #perform_delay\n\n def perform_delay(error = nil) -\u003e Boolean\n\n**Alias Of** : [#call](./Gapic-Common-RetryPolicy#Gapic__Common__RetryPolicy_call_instance_) \nPerform delay if and only if retriable.\n\n\n\u003cbr /\u003e\n\nIf positional argument `error` is provided, the retriable logic uses\n`retry_codes`. Otherwise, `timeout` is used. \n**Returns**\n\n- (Boolean) --- Whether the delay was executed.\n\n### #perform_delay!\n\n def perform_delay!() -\u003e Boolean\n\nPerform delay. \n**Returns**\n\n- (Boolean) --- Whether the delay was executed.\n\n### #perform_delay_count\n\n def perform_delay_count() -\u003e Integer\n\nCurrent number of times the delay has been performed \n**Returns**\n\n- (Integer)\n\n### #retry_codes\n\n def retry_codes() -\u003e Array\u003cInteger\u003e\n\n**Returns**\n\n- (Array\\\u003cInteger\\\u003e) --- List of retry codes.\n\n### #start!\n\n def start!(mock_delay: false)\n\nStart tracking the deadline and delay by initializing those values.\n\n\n\u003cbr /\u003e\n\nThis is normally done when the object is constructed, but it can be\ndone explicitly in order to reinitialize the state in case this\nretry policy was created in the past or is being reused. \n**Parameter**\n\n- **mock_delay** (boolean, Proc) *(defaults to: false)* --- if truthy, delays are \"mocked\", meaning they do not actually take time, but are measured as if they did, which is useful for tests. If set to a Proc, it will be called whenever a delay would happen, and passed the delay in seconds, also useful for testing.\n\n### #timeout\n\n def timeout() -\u003e Numeric\n\n**Returns**\n\n- (Numeric) --- Timeout threshold value in seconds.\n\nConstants\n---------\n\n### DEFAULT_INITIAL_DELAY\n\n**value:**1\n\n### DEFAULT_MAX_DELAY\n\n**value:**15\n\n### DEFAULT_MULTIPLIER\n\n**value:**1.3\n\n### DEFAULT_RETRY_CODES\n\n**value:**\\[\\].freeze\n\n### DEFAULT_TIMEOUT\n\n**value:**3600"]]