Class: Consul::Async::JSONResult

Inherits:
Object
  • Object
show all
Defined in:
lib/consul/async/json_endpoint.rb

Overview

Result from call to a Remote JSON endpoint

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, modified, http, stats, retry_in, fake: false) ⇒ JSONResult

Returns a new instance of JSONResult.



47
48
49
50
51
52
53
54
55
# File 'lib/consul/async/json_endpoint.rb', line 47

def initialize(data, modified, http, stats, retry_in, fake: false)
  @data = data
  @modified = modified
  @http = http
  @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.



46
47
48
# File 'lib/consul/async/json_endpoint.rb', line 46

def data
  @data
end

#httpObject (readonly)

Returns the value of attribute http.



46
47
48
# File 'lib/consul/async/json_endpoint.rb', line 46

def http
  @http
end

#last_updateObject (readonly)

Returns the value of attribute last_update.



46
47
48
# File 'lib/consul/async/json_endpoint.rb', line 46

def last_update
  @last_update
end

#retry_inObject (readonly)

Returns the value of attribute retry_in.



46
47
48
# File 'lib/consul/async/json_endpoint.rb', line 46

def retry_in
  @retry_in
end

#statsObject (readonly)

Returns the value of attribute stats.



46
47
48
# File 'lib/consul/async/json_endpoint.rb', line 46

def stats
  @stats
end

Instance Method Details

#fake?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/consul/async/json_endpoint.rb', line 57

def fake?
  @fake
end

#jsonObject



70
71
72
# File 'lib/consul/async/json_endpoint.rb', line 70

def json
  @json ||= JSON.parse(data)
end

#modified?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/consul/async/json_endpoint.rb', line 61

def modified?
  @modified
end

#mutate(new_data) ⇒ Object



65
66
67
68
# File 'lib/consul/async/json_endpoint.rb', line 65

def mutate(new_data)
  @data = new_data.dup
  @json = nil
end

#next_retry_atObject



74
75
76
# File 'lib/consul/async/json_endpoint.rb', line 74

def next_retry_at
  next_retry + last_update
end