Class: Mongo::Retryable::RetryPolicy Private
- Inherits:
-
Object
- Object
- Mongo::Retryable::RetryPolicy
- Defined in:
- lib/mongo/retryable/retry_policy.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Encapsulates the retry policy for client backpressure with exponential backoff and jitter.
One instance is created per Client and shared across all operations on that client.
Instance Attribute Summary collapse
-
#max_retries ⇒ Integer
readonly
private
The maximum number of overload retries.
Instance Method Summary collapse
-
#backoff_delay(attempt, jitter: rand) ⇒ Float
private
Calculate the backoff delay for a given retry attempt.
-
#initialize(max_retries: Backpressure::DEFAULT_MAX_RETRIES) ⇒ RetryPolicy
constructor
private
Create a new retry policy.
-
#should_retry_overload?(attempt, delay, context: nil) ⇒ true | false
private
Determine whether an overload retry should be attempted.
Constructor Details
#initialize(max_retries: Backpressure::DEFAULT_MAX_RETRIES) ⇒ RetryPolicy
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a new retry policy.
20 21 22 |
# File 'lib/mongo/retryable/retry_policy.rb', line 20 def initialize(max_retries: Backpressure::DEFAULT_MAX_RETRIES) @max_retries = max_retries end |
Instance Attribute Details
#max_retries ⇒ Integer (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The maximum number of overload retries.
14 15 16 |
# File 'lib/mongo/retryable/retry_policy.rb', line 14 def max_retries @max_retries end |
Instance Method Details
#backoff_delay(attempt, jitter: rand) ⇒ Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Calculate the backoff delay for a given retry attempt.
30 31 32 |
# File 'lib/mongo/retryable/retry_policy.rb', line 30 def backoff_delay(attempt, jitter: rand) Backpressure.backoff_delay(attempt, jitter: jitter) end |
#should_retry_overload?(attempt, delay, context: nil) ⇒ true | false
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Determine whether an overload retry should be attempted.
42 43 44 45 46 47 |
# 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 |