Class: SensuGenerator::ConsulService
- Inherits:
-
Consul
- Object
- Consul
- SensuGenerator::ConsulService
show all
- Defined in:
- lib/sensu_generator/consul/consul_service.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Consul
#get_service_props, #kv_svc_props, #sensu_servers, #services
Constructor Details
Returns a new instance of ConsulService.
6
7
8
9
10
11
12
|
# File 'lib/sensu_generator/consul/consul_service.rb', line 6
def initialize(name:)
@name = name
@changed = true
super()
all_properties
self
end
|
Instance Attribute Details
#checks ⇒ Object
Returns the value of attribute checks.
4
5
6
|
# File 'lib/sensu_generator/consul/consul_service.rb', line 4
def checks
@checks
end
|
#name ⇒ Object
Returns the value of attribute name.
4
5
6
|
# File 'lib/sensu_generator/consul/consul_service.rb', line 4
def name
@name
end
|
#properties ⇒ Object
Returns the value of attribute properties.
4
5
6
|
# File 'lib/sensu_generator/consul/consul_service.rb', line 4
def properties
@properties
end
|
Instance Method Details
#all_properties ⇒ Object
Also known as:
get_all_properties
14
15
16
17
|
# File 'lib/sensu_generator/consul/consul_service.rb', line 14
def all_properties
properties = get_props.class == Array ? get_props.map {|el| el.to_h} : get_props.to_h
@all_properties ||= { checks: get_checks, properties: properties }
end
|
#changed? ⇒ Boolean
36
37
38
|
# File 'lib/sensu_generator/consul/consul_service.rb', line 36
def changed?
@changed
end
|
#get_checks ⇒ Object
21
22
23
|
# File 'lib/sensu_generator/consul/consul_service.rb', line 21
def get_checks
@checks ||= kv_svc_props(key: config.get[:kv_tags_path])
end
|
#get_props ⇒ Object
25
26
27
|
# File 'lib/sensu_generator/consul/consul_service.rb', line 25
def get_props
@properties ||= get_service_props(name)
end
|
#reset ⇒ Object
40
41
42
43
44
45
|
# File 'lib/sensu_generator/consul/consul_service.rb', line 40
def reset
@all_properties = nil
@properties = nil
@checks = nil
@changed = false
end
|
#update ⇒ Object
29
30
31
32
33
34
|
# File 'lib/sensu_generator/consul/consul_service.rb', line 29
def update
old_all_properties = all_properties.clone
reset
get_all_properties
@changed = true if all_properties != old_all_properties
end
|