Class: Couchbase::Protostellar::Request Private
- Inherits:
-
Object
- Object
- Couchbase::Protostellar::Request
- Defined in:
- lib/couchbase/protostellar/request.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.
Instance Attribute Summary collapse
- #context ⇒ Object private
- #idempotent ⇒ Object readonly private
- #proto_request ⇒ Object readonly private
- #retry_attempts ⇒ Object readonly private
- #retry_reasons ⇒ Object readonly private
- #retry_strategy ⇒ Object readonly private
- #rpc ⇒ Object readonly private
- #service ⇒ Object readonly private
- #timeout ⇒ Object readonly private
Instance Method Summary collapse
- #add_retry_attempt(reason) ⇒ Object private
- #deadline ⇒ Object private
- #error_context ⇒ Object private
-
#initialize(service:, rpc:, proto_request:, timeout:, retry_strategy: Retry::Strategies::BestEffort::DEFAULT, idempotent: false) ⇒ Request
constructor
private
A new instance of Request.
- #set_timeout_from_defaults(timeouts) ⇒ Object private
Constructor Details
#initialize(service:, rpc:, proto_request:, timeout:, retry_strategy: Retry::Strategies::BestEffort::DEFAULT, idempotent: false) ⇒ Request
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 Request.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/couchbase/protostellar/request.rb', line 34 def initialize( service:, rpc:, proto_request:, timeout:, retry_strategy: Retry::Strategies::BestEffort::DEFAULT, idempotent: false ) @service = service @rpc = rpc @timeout = timeout @deadline = nil @proto_request = proto_request @idempotent = idempotent @retry_attempts = 0 @retry_reasons = Set.new @retry_strategy = retry_strategy @context = {} end |
Instance Attribute Details
#context ⇒ 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.
32 33 34 |
# File 'lib/couchbase/protostellar/request.rb', line 32 def context @context end |
#idempotent ⇒ 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.
28 29 30 |
# File 'lib/couchbase/protostellar/request.rb', line 28 def idempotent @idempotent end |
#proto_request ⇒ 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.
27 28 29 |
# File 'lib/couchbase/protostellar/request.rb', line 27 def proto_request @proto_request end |
#retry_attempts ⇒ 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.
29 30 31 |
# File 'lib/couchbase/protostellar/request.rb', line 29 def retry_attempts @retry_attempts end |
#retry_reasons ⇒ 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.
30 31 32 |
# File 'lib/couchbase/protostellar/request.rb', line 30 def retry_reasons @retry_reasons end |
#retry_strategy ⇒ 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.
31 32 33 |
# File 'lib/couchbase/protostellar/request.rb', line 31 def retry_strategy @retry_strategy end |
#rpc ⇒ 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.
25 26 27 |
# File 'lib/couchbase/protostellar/request.rb', line 25 def rpc @rpc end |
#service ⇒ 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.
24 25 26 |
# File 'lib/couchbase/protostellar/request.rb', line 24 def service @service end |
#timeout ⇒ 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.
26 27 28 |
# File 'lib/couchbase/protostellar/request.rb', line 26 def timeout @timeout end |
Instance Method Details
#add_retry_attempt(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.
62 63 64 65 |
# File 'lib/couchbase/protostellar/request.rb', line 62 def add_retry_attempt(reason) @retry_reasons.add(reason) @retry_attempts += 1 end |
#deadline ⇒ 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.
54 55 56 57 58 59 60 |
# File 'lib/couchbase/protostellar/request.rb', line 54 def deadline if @deadline.nil? timeout_secs = 0.001 * Utils::Time.extract_duration(@timeout) @deadline = Time.now + timeout_secs end @deadline end |
#error_context ⇒ 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.
67 68 69 |
# File 'lib/couchbase/protostellar/request.rb', line 67 def error_context @context.merge({retry_reasons: @retry_reasons.to_a, retry_attempts: @retry_attempts}) end |
#set_timeout_from_defaults(timeouts) ⇒ 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.
71 72 73 74 75 |
# File 'lib/couchbase/protostellar/request.rb', line 71 def set_timeout_from_defaults(timeouts) return unless @timeout.nil? @timeout = timeouts.timeout_for_request(self) end |