Class: ConsulService
- Inherits:
-
Object
- Object
- ConsulService
- Extended by:
- ConsulConfiguration
- Defined in:
- lib/consul/consul_service.rb
Constant Summary
Constants included from ConsulConfiguration
Instance Attribute Summary collapse
-
#consul_service_data ⇒ Object
Returns the value of attribute consul_service_data.
Instance Method Summary collapse
-
#initialize(option = nil) ⇒ ConsulService
constructor
A new instance of ConsulService.
- #start ⇒ Object
- #stop ⇒ Object
Methods included from ConsulConfiguration
Methods included from ApplicationConfiguration
#config, #config_consul, #config_rest, #random_name
Constructor Details
#initialize(option = nil) ⇒ ConsulService
Returns a new instance of ConsulService.
11 12 13 14 |
# File 'lib/consul/consul_service.rb', line 11 def initialize(option=nil) puts 'init consul' self.consul_service_data = ConsulService.configure end |
Instance Attribute Details
#consul_service_data ⇒ Object
Returns the value of attribute consul_service_data.
9 10 11 |
# File 'lib/consul/consul_service.rb', line 9 def consul_service_data @consul_service_data end |
Instance Method Details
#start ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/consul/consul_service.rb', line 16 def start puts 'start consul' puts ConsulConfiguration::CONFIG[:consul_check_http] consul_service_data = ConsulConfiguration::CONFIG[:consul_service_data] if consul_service_data.nil? Diplomat::Service.register(consul_service_data) # start url for consul to check health RestService.start_consul_check_http(ConsulConfiguration::CONFIG[:consul_check_http]) end |
#stop ⇒ Object
25 26 27 28 |
# File 'lib/consul/consul_service.rb', line 25 def stop puts 'stop consul' Diplomat::Service.deregister(consul_service_data[:id]) end |