Class: Couchbase::Protostellar::Request Private

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/protostellar/request.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.

API:

  • private

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

API:

  • private



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

#contextObject

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.

API:

  • private



32
33
34
# File 'lib/couchbase/protostellar/request.rb', line 32

def context
  @context
end

#idempotentObject (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.

API:

  • private



28
29
30
# File 'lib/couchbase/protostellar/request.rb', line 28

def idempotent
  @idempotent
end

#proto_requestObject (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.

API:

  • private



27
28
29
# File 'lib/couchbase/protostellar/request.rb', line 27

def proto_request
  @proto_request
end

#retry_attemptsObject (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.

API:

  • private



29
30
31
# File 'lib/couchbase/protostellar/request.rb', line 29

def retry_attempts
  @retry_attempts
end

#retry_reasonsObject (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.

API:

  • private



30
31
32
# File 'lib/couchbase/protostellar/request.rb', line 30

def retry_reasons
  @retry_reasons
end

#retry_strategyObject (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.

API:

  • private



31
32
33
# File 'lib/couchbase/protostellar/request.rb', line 31

def retry_strategy
  @retry_strategy
end

#rpcObject (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.

API:

  • private



25
26
27
# File 'lib/couchbase/protostellar/request.rb', line 25

def rpc
  @rpc
end

#serviceObject (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.

API:

  • private



24
25
26
# File 'lib/couchbase/protostellar/request.rb', line 24

def service
  @service
end

#timeoutObject (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.

API:

  • private



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.

API:

  • private



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

#deadlineObject

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.

API:

  • private



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_contextObject

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.

API:

  • private



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.

API:

  • private



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