Class: ConsulBridge::DetectConsul

Inherits:
Object
  • Object
show all
Includes:
Metaractor
Defined in:
lib/consul_bridge/detect_consul.rb

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#callObject



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

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

  context.running = running
end