Class: Mongo::Retryable::RetryPolicy Private
Do not use. This class is for internal use only.
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | lib/mongo/retryable/retry_policy.rb |
Overview
Encapsulates the retry policy for client backpressure with exponential backoff and jitter.
One instance is created per ::Mongo::Client and shared across all operations on that client.
Class Method Summary
-
.new(max_retries: Backpressure::DEFAULT_MAX_RETRIES) ⇒ RetryPolicy
constructor
Internal use only
Create a new retry policy.
Instance Attribute Summary
- #max_retries ⇒ Integer readonly Internal use only
Instance Method Summary
-
#backoff_delay(attempt, jitter: rand) ⇒ Float
Internal use only
Calculate the backoff delay for a given retry attempt.
-
#should_retry_overload?(attempt, delay, context: nil) ⇒ true | false
Internal use only
Determine whether an overload retry should be attempted.
- #exceeds_deadline?(delay, context) ⇒ Boolean private Internal use only
Instance Attribute Details
#max_retries ⇒ Integer (readonly)
# File 'lib/mongo/retryable/retry_policy.rb', line 14
attr_reader :max_retries
Instance Method Details
#backoff_delay(attempt, jitter: rand) ⇒ Float
Calculate the backoff delay for a given retry attempt.
# File 'lib/mongo/retryable/retry_policy.rb', line 30
def backoff_delay(attempt, jitter: rand) Backpressure.backoff_delay(attempt, jitter: jitter) end
#exceeds_deadline?(delay, context) ⇒ Boolean (private)
# File 'lib/mongo/retryable/retry_policy.rb', line 51
def exceeds_deadline?(delay, context) return false unless context&.csot? deadline = context&.deadline deadline&.nonzero? && Utils.monotonic_time + delay > deadline end
#should_retry_overload?(attempt, delay, context: nil) ⇒ true | false
Determine whether an overload retry should be attempted.
# File 'lib/mongo/retryable/retry_policy.rb', line 42
def should_retry_overload?(attempt, delay, context: nil) return false if attempt > @max_retries return false if exceeds_deadline?(delay, context) true end