Class: Consul::Async::ConsulResult
- Inherits:
-
Object
- Object
- Consul::Async::ConsulResult
- Defined in:
- lib/consul/async/consul_endpoint.rb
Overview
This keep track of answer from Consul It also keep statistics about result (x_consul_index, stats...)
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#last_update ⇒ Object
readonly
Returns the value of attribute last_update.
-
#retry_in ⇒ Object
readonly
Returns the value of attribute retry_in.
-
#stats ⇒ Object
readonly
Returns the value of attribute stats.
-
#x_consul_index ⇒ Object
readonly
Returns the value of attribute x_consul_index.
Instance Method Summary collapse
- #fake? ⇒ Boolean
-
#initialize(data, modified, http, x_consul_index, stats, retry_in, fake: false) ⇒ ConsulResult
constructor
A new instance of ConsulResult.
- #json ⇒ Object
- #modified? ⇒ Boolean
- #mutate(new_data) ⇒ Object
- #next_retry_at ⇒ Object
Constructor Details
#initialize(data, modified, http, x_consul_index, stats, retry_in, fake: false) ⇒ ConsulResult
Returns a new instance of ConsulResult.
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/consul/async/consul_endpoint.rb', line 93 def initialize(data, modified, http, x_consul_index, stats, retry_in, fake: false) @data = data @modified = modified @http = http @x_consul_index = x_consul_index @last_update = Time.now.utc @stats = stats @retry_in = retry_in @fake = fake end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
91 92 93 |
# File 'lib/consul/async/consul_endpoint.rb', line 91 def data @data end |
#http ⇒ Object (readonly)
Returns the value of attribute http.
91 92 93 |
# File 'lib/consul/async/consul_endpoint.rb', line 91 def http @http end |
#last_update ⇒ Object (readonly)
Returns the value of attribute last_update.
91 92 93 |
# File 'lib/consul/async/consul_endpoint.rb', line 91 def last_update @last_update end |
#retry_in ⇒ Object (readonly)
Returns the value of attribute retry_in.
91 92 93 |
# File 'lib/consul/async/consul_endpoint.rb', line 91 def retry_in @retry_in end |
#stats ⇒ Object (readonly)
Returns the value of attribute stats.
91 92 93 |
# File 'lib/consul/async/consul_endpoint.rb', line 91 def stats @stats end |
#x_consul_index ⇒ Object (readonly)
Returns the value of attribute x_consul_index.
91 92 93 |
# File 'lib/consul/async/consul_endpoint.rb', line 91 def x_consul_index @x_consul_index end |
Instance Method Details
#fake? ⇒ Boolean
104 105 106 |
# File 'lib/consul/async/consul_endpoint.rb', line 104 def fake? @fake end |
#json ⇒ Object
117 118 119 120 |
# File 'lib/consul/async/consul_endpoint.rb', line 117 def json @data_json = JSON.parse(data) if @data_json.nil? @data_json end |
#modified? ⇒ Boolean
108 109 110 |
# File 'lib/consul/async/consul_endpoint.rb', line 108 def modified? @modified end |
#mutate(new_data) ⇒ Object
112 113 114 115 |
# File 'lib/consul/async/consul_endpoint.rb', line 112 def mutate(new_data) @data = new_data.dup @data_json = nil end |
#next_retry_at ⇒ Object
122 123 124 |
# File 'lib/consul/async/consul_endpoint.rb', line 122 def next_retry_at next_retry + last_update end |