Class: Philae::NSQClusterProbe
- Inherits:
-
CollectionProbe
- Object
- CollectionProbe
- Philae::NSQClusterProbe
- Defined in:
- lib/philae/nsq_cluster_probe.rb
Constant Summary collapse
- DEFAULT_HTTP_PORT =
4152
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#nsq_probes ⇒ Object
readonly
Returns the value of attribute nsq_probes.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, hosts, tls_context = nil) ⇒ NSQClusterProbe
constructor
A new instance of NSQClusterProbe.
- #probes ⇒ Object
Methods inherited from CollectionProbe
Constructor Details
#initialize(name, hosts, tls_context = nil) ⇒ NSQClusterProbe
Returns a new instance of NSQClusterProbe.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/philae/nsq_cluster_probe.rb', line 31 def initialize(name, hosts, tls_context = nil) raise ArgumentError, 'should have at least one host' if hosts.nil? || hosts.empty? @name = name @nsq_probes = hosts.map do |hostport| host, port = hostport.split(':') port = DEFAULT_HTTP_PORT if port.nil? next Philae::NSQProbe.new("#{name}-#{host}-#{port}", host, port, tls_context) end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/philae/nsq_cluster_probe.rb', line 8 def name @name end |
#nsq_probes ⇒ Object (readonly)
Returns the value of attribute nsq_probes.
8 9 10 |
# File 'lib/philae/nsq_cluster_probe.rb', line 8 def nsq_probes @nsq_probes end |
Class Method Details
.new_from_env(name) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/philae/nsq_cluster_probe.rb', line 10 def self.new_from_env(name) if ENV['NSQD_HOSTS'].nil? || ENV['NSQD_HTTP_PORT'].nil? raise ArgumentError, 'no NSQD_HOSTS and NSQD_HTTP_PORT defined' end tls_context = nil if ENV['NSQD_TLS'] == 'true' tls_context = { cert: ENV['NSQD_TLS_CERT'], key: ENV['NSQD_TLS_KEY'], ca: ENV['NSQD_TLS_CACERT'], } end http_hosts = ENV['NSQD_HOSTS'].split(',').map do |host| host.split(':')[0] + ":#{ENV['NSQD_HTTP_PORT']}" end new(name, http_hosts, tls_context) end |
Instance Method Details
#probes ⇒ Object
42 43 44 |
# File 'lib/philae/nsq_cluster_probe.rb', line 42 def probes @nsq_probes end |