Class: Nerve::Reporter::Etcd
- Inherits:
-
Base
- Object
- Base
- Nerve::Reporter::Etcd
show all
- Defined in:
- lib/nerve/reporter/etcd.rb
Instance Method Summary
collapse
Methods inherited from Base
#get_service_data
Methods included from Logging
configure_logger_for, #log, logger_for
Methods included from Utils
#responsive_sleep, #safe_run
Constructor Details
#initialize(service) ⇒ Etcd
Returns a new instance of Etcd.
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/nerve/reporter/etcd.rb', line 6
def initialize(service)
raise ArgumentError, "missing required argument etcd_host for new service watcher" unless service['etcd_host']
@host = service['etcd_host']
@port = service['etcd_port'] || 4003
path = service['etcd_path'] || '/'
@path = path.split('/').push(service['instance_id']).join('/')
@data = parse_data(get_service_data(service))
@key = nil
@ttl = (service['check_interval'] || 0.5) * 5
@ttl = @ttl.ceil
end
|
Instance Method Details
#ping? ⇒ Boolean
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/nerve/reporter/etcd.rb', line 37
def ping?
if @key
etcd_save
else
@etcd.leader
end
end
|
#report_down ⇒ Object
33
34
35
|
# File 'lib/nerve/reporter/etcd.rb', line 33
def report_down
etcd_delete
end
|
#report_up ⇒ Object
29
30
31
|
# File 'lib/nerve/reporter/etcd.rb', line 29
def report_up()
etcd_save
end
|
#start ⇒ Object
18
19
20
21
22
|
# File 'lib/nerve/reporter/etcd.rb', line 18
def start()
log.info "nerve: connecting to etcd at #{@host}:#{@port}"
@etcd = ::Etcd.client(:host => @host, :port => @port)
log.info "nerve: successfully created etcd connection to #{@host}:#{@port}"
end
|
#stop ⇒ Object
24
25
26
27
|
# File 'lib/nerve/reporter/etcd.rb', line 24
def stop()
report_down
@etcd = nil
end
|