Class: Couchbase::Protostellar::Retry::Strategies::BestEffort Private
- Inherits:
-
Object
- Object
- Couchbase::Protostellar::Retry::Strategies::BestEffort
- Defined in:
- lib/couchbase/protostellar/retry/strategies/best_effort.rb
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.
Constant Summary collapse
- DEFAULT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
BestEffort.new.freeze
Instance Attribute Summary collapse
- #backoff_calculator ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(backoff_calculator = nil) ⇒ BestEffort
constructor
private
A new instance of BestEffort.
- #retry_after(request, reason) ⇒ Object private
Constructor Details
#initialize(backoff_calculator = nil) ⇒ BestEffort
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 a new instance of BestEffort.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/couchbase/protostellar/retry/strategies/best_effort.rb', line 24 def initialize(backoff_calculator = nil) # The default backoff calculator starts with a 1 millisecond backoff and doubles it after each retry # attempt, up to a maximum of 500 milliseconds @backoff_calculator = if backoff_calculator.nil? lambda { |retry_attempt_count| [2**retry_attempt_count, 500].min } else backoff_calculator end end |
Instance Attribute Details
#backoff_calculator ⇒ Object (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.
22 23 24 |
# File 'lib/couchbase/protostellar/retry/strategies/best_effort.rb', line 22 def backoff_calculator @backoff_calculator end |
Instance Method Details
#retry_after(request, reason) ⇒ Object
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.
35 36 37 38 39 40 41 42 |
# File 'lib/couchbase/protostellar/retry/strategies/best_effort.rb', line 35 def retry_after(request, reason) if request.idempotent || reason.allows_non_idempotent_retry backoff = @backoff_calculator.call(request.retry_attempts) Retry::Action.with_duration(backoff) else Retry::Action.no_retry end end |