Class: Smartsheet::API::RetryLogic
- Inherits:
-
Object
- Object
- Smartsheet::API::RetryLogic
- Includes:
- Constants
- Defined in:
- lib/smartsheet/api/retry_logic.rb
Overview
Accepts a callable proc and a predicate, calling the proc repeatedly with backoff until the provided time limit is reached, or until the predicate applied to the proc's result returns false.
Constant Summary
Constants included from Constants
Constants::API_URL, Constants::CSV_TYPE, Constants::DEFAULT_BACKOFF_METHOD, Constants::DEFAULT_MAX_RETRY_TIME, Constants::EXCEL_TYPE, Constants::JSON_TYPE, Constants::OPENXML_SPREADSHEET_TYPE, Constants::PDF_TYPE, Constants::USER_AGENT, Constants::VERSION
Instance Method Summary collapse
-
#initialize(max_retry_time: DEFAULT_MAX_RETRY_TIME, backoff_method: DEFAULT_BACKOFF_METHOD) ⇒ RetryLogic
constructor
A new instance of RetryLogic.
- #run(should_retry, &method_to_run) ⇒ Object
Constructor Details
#initialize(max_retry_time: DEFAULT_MAX_RETRY_TIME, backoff_method: DEFAULT_BACKOFF_METHOD) ⇒ RetryLogic
Returns a new instance of RetryLogic.
11 12 13 14 |
# File 'lib/smartsheet/api/retry_logic.rb', line 11 def initialize(max_retry_time: DEFAULT_MAX_RETRY_TIME, backoff_method: DEFAULT_BACKOFF_METHOD) @max_retry_time = max_retry_time @backoff_method = backoff_method end |
Instance Method Details
#run(should_retry, &method_to_run) ⇒ Object
16 17 18 19 20 |
# File 'lib/smartsheet/api/retry_logic.rb', line 16 def run(should_retry, &method_to_run) end_time = Time.now.to_i + max_retry_time _run(method_to_run, should_retry, end_time, 0) end |