Class: Philae::NSQProbe

Inherits:
HttpProbe show all
Defined in:
lib/philae/nsq_probe.rb

Instance Attribute Summary

Attributes inherited from HttpProbe

#name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from HttpProbe

#check

Constructor Details

#initialize(name, host, port = 4151, tls_context = nil, opts = {}) ⇒ NSQProbe

Returns a new instance of NSQProbe.



17
18
19
20
21
22
23
24
25
26
# File 'lib/philae/nsq_probe.rb', line 17

def initialize(name, host, port = 4151, tls_context = nil, opts = {})
  @name = name
  scheme = "http"
  if !tls_context.nil?
    scheme = "https"
  end
  @uri = "#{scheme}://#{host}:#{port}/ping"
  @tls_context = tls_context
  @timeout = opts.fetch(:timeout, 5)
end

Class Method Details

.new_from_env(name, opts = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/philae/nsq_probe.rb', line 5

def self.new_from_env(name, opts = {})
  if ENV["NSQD_TLS"] == "true"
    return self.new(name, ENV["NSQD_HOST"], ENV["NSQD_HTTP_PORT"], {
      cert: ENV["NSQD_TLS_CERT"],
      key:  ENV["NSQD_TLS_KEY"],
      ca:   ENV["NSQD_TLS_CACERT"],
    }, opts)
  else
    return self.new(name, ENV["NSQD_HOST"], ENV["NSQD_HTTP_PORT"])
  end
end