Class: Consul::Async::ConsulResult

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#dataObject (readonly)

Returns the value of attribute data.



90
91
92
# File 'lib/consul/async/consul_endpoint.rb', line 90

def data
  @data
end

#httpObject (readonly)

Returns the value of attribute http.



90
91
92
# File 'lib/consul/async/consul_endpoint.rb', line 90

def http
  @http
end

#last_updateObject (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_inObject (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

#statsObject (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_indexObject (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

Returns:

  • (Boolean)


102
103
104
# File 'lib/consul/async/consul_endpoint.rb', line 102

def fake?
  @fake
end

#jsonObject



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

Returns:

  • (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_atObject



120
121
122
# File 'lib/consul/async/consul_endpoint.rb', line 120

def next_retry_at
  next_retry + last_update
end