Class: WhatsAppNotifier::Bulk::RetryPolicy
- Inherits:
-
Object
- Object
- WhatsAppNotifier::Bulk::RetryPolicy
- Defined in:
- lib/whatsapp_notifier/bulk/retry_policy.rb
Instance Method Summary collapse
-
#initialize(max_attempts:, retryable_error_codes:) ⇒ RetryPolicy
constructor
A new instance of RetryPolicy.
- #with_retries ⇒ Object
Constructor Details
#initialize(max_attempts:, retryable_error_codes:) ⇒ RetryPolicy
Returns a new instance of RetryPolicy.
4 5 6 7 |
# File 'lib/whatsapp_notifier/bulk/retry_policy.rb', line 4 def initialize(max_attempts:, retryable_error_codes:) @max_attempts = max_attempts @retryable_error_codes = retryable_error_codes end |
Instance Method Details
#with_retries ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/whatsapp_notifier/bulk/retry_policy.rb', line 9 def with_retries attempts = 0 result = nil loop do attempts += 1 result = yield(attempts) break unless retry?(result, attempts) end result end |