19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/consul_stockpile/watch_event.rb', line 19
def call
Logger.tagged('WatchEvent') do
Logger.info "Watching for event: #{EVENT}"
response = Excon.get(
URL,
query: {name: EVENT},
expects: [200],
connect_timeout: 5,
read_timeout: 5,
write_timeout: 5,
tcp_nodelay: true
)
handle_events(response.body)
loop do
index = response.['X-Consul-Index']
response = Excon.get(
URL,
query: {name: EVENT, index: index},
expects: [200],
connect_timeout: 5,
read_timeout: 86400,
write_timeout: 5,
tcp_nodelay: true
)
handle_events(response.body)
end
end
end
|