Class: SensuGenerator::ConsulState
- Inherits:
-
Consul
- Object
- Consul
- SensuGenerator::ConsulState
show all
- Defined in:
- lib/sensu_generator/consul/consul_state.rb
Instance Method Summary
collapse
Methods inherited from Consul
#get_service_props, #kv_svc_props, #sensu_servers, #services
Constructor Details
Returns a new instance of ConsulState.
3
4
5
6
7
|
# File 'lib/sensu_generator/consul/consul_state.rb', line 3
def initialize
@actual_state = []
super()
actualize
end
|
Instance Method Details
#actualize ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/sensu_generator/consul/consul_state.rb', line 13
def actualize
reset
@svc_list_diff = services.map {|name, _| name.to_s } - @actual_state.map { |svc| svc.name.to_s}
@actual_state.each(&:update)
@svc_list_diff.each do |name|
@actual_state << ConsulService.new(name: name)
end
@actualized = true
logger.debug "Services actualized list: #{@actual_state.map { |svc| svc.name.to_s} }"
self
end
|
#actualized? ⇒ Boolean
41
42
43
|
# File 'lib/sensu_generator/consul/consul_state.rb', line 41
def actualized?
@actualized ? true : false end
|
#changed? ⇒ Boolean
25
26
27
28
29
|
# File 'lib/sensu_generator/consul/consul_state.rb', line 25
def changed?
state = !(@svc_list_diff || []).empty? || !changes.empty?
logger.debug "Consul state was changed: #{state.to_s}"
state
end
|
#changes ⇒ Object
31
32
33
|
# File 'lib/sensu_generator/consul/consul_state.rb', line 31
def changes
@svc_changes ||= @actual_state.select(&:changed?)
end
|
#reset ⇒ Object
35
36
37
38
39
|
# File 'lib/sensu_generator/consul/consul_state.rb', line 35
def reset
@actualized = false
@svc_changes = nil
@svc_list_diff = nil
end
|
#show ⇒ Object
9
10
11
|
# File 'lib/sensu_generator/consul/consul_state.rb', line 9
def show
@actual_state
end
|