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.
91 92 93 94 95 96 97 98 99 100 |
# File 'lib/consul/async/consul_endpoint.rb', line 91 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.
90 91 92 |
# File 'lib/consul/async/consul_endpoint.rb', line 90 def data @data end |
#http ⇒ Object (readonly)
Returns the value of attribute http.
90 91 92 |
# File 'lib/consul/async/consul_endpoint.rb', line 90 def http @http end |
#last_update ⇒ Object (readonly)
Returns the value of attribute last_update.
90 91 92 |
# File 'lib/consul/async/consul_endpoint.rb', line 90 def last_update @last_update end |
#retry_in ⇒ Object (readonly)
Returns the value of attribute retry_in.
90 91 92 |
# File 'lib/consul/async/consul_endpoint.rb', line 90 def retry_in @retry_in end |
#stats ⇒ Object (readonly)
Returns the value of attribute stats.
90 91 92 |
# File 'lib/consul/async/consul_endpoint.rb', line 90 def stats @stats end |
#x_consul_index ⇒ Object (readonly)
Returns the value of attribute x_consul_index.
90 91 92 |
# File 'lib/consul/async/consul_endpoint.rb', line 90 def x_consul_index @x_consul_index end |
Instance Method Details
#fake? ⇒ Boolean
102 103 104 |
# File 'lib/consul/async/consul_endpoint.rb', line 102 def fake? @fake end |
#json ⇒ Object
115 116 117 118 |
# File 'lib/consul/async/consul_endpoint.rb', line 115 def json @data_json = JSON.parse(data) if @data_json.nil? @data_json end |
#modified? ⇒ Boolean
106 107 108 |
# File 'lib/consul/async/consul_endpoint.rb', line 106 def modified? @modified end |
#mutate(new_data) ⇒ Object
110 111 112 113 |
# File 'lib/consul/async/consul_endpoint.rb', line 110 def mutate(new_data) @data = new_data.dup @data_json = nil end |
#next_retry_at ⇒ Object
120 121 122 |
# File 'lib/consul/async/consul_endpoint.rb', line 120 def next_retry_at next_retry + last_update end |