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.



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

#dataObject (readonly)

Returns the value of attribute data.



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

def data
  @data
end

#httpObject (readonly)

Returns the value of attribute http.



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

def http
  @http
end

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

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

Returns:

  • (Boolean)


104
105
106
# File 'lib/consul/async/consul_endpoint.rb', line 104

def fake?
  @fake
end

#jsonObject



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

Returns:

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



122
123
124
# File 'lib/consul/async/consul_endpoint.rb', line 122

def next_retry_at
  next_retry + last_update
end