Class: Couchbase::Protostellar::Retry::Orchestrator Private
- Inherits:
-
Object
- Object
- Couchbase::Protostellar::Retry::Orchestrator
- Defined in:
- lib/couchbase/protostellar/retry/orchestrator.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.
Class Method Summary collapse
Class Method Details
.get_controlled_backoff(request) ⇒ 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.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/couchbase/protostellar/retry/orchestrator.rb', line 47 def self.get_controlled_backoff(request) case request.retry_attempts when 0 then 1 when 1 then 10 when 2 then 50 when 3 then 100 when 4 then 500 else 1000 end end |
.maybe_retry(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.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/couchbase/protostellar/retry/orchestrator.rb', line 27 def self.maybe_retry(request, reason) if reason.always_retry retry_duration = get_controlled_backoff(request) request.add_retry_attempt(reason) # TODO: Log retry RequestBehaviour.retry(retry_duration) else retry_action = request.retry_strategy.retry_after(request, reason) duration = retry_action.duration if duration.nil? # TODO: Log not retried RequestBehaviour.fail(Couchbase::Error::RequestCanceled.new('Cannot retry request', request.error_context)) else request.add_retry_attempt(reason) # TODO: Log retry RequestBehaviour.retry(duration) end end end |