Class: ConsulStockpile::DetectConsul

Inherits:
Base
  • Object
show all
Defined in:
lib/consul_stockpile/detect_consul.rb

Constant Summary collapse

URL =
'http://127.0.0.1:8500/v1/agent/self'.freeze

Instance Method Summary collapse

Methods inherited from Base

call

Instance Method Details

#callObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/consul_stockpile/detect_consul.rb', line 8

def call
  running = true
  begin
    Excon.get(
      URL,
      expects: [200],
      connect_timeout: 5,
      read_timeout: 5,
      write_timeout: 5,
      tcp_nodelay: true
    )
  rescue Excon::Errors::SocketError, Excon::Errors::HTTPStatusError
    running = false
  end
  OpenStruct.new(
    running: running
  )
end