Class: Nsqlookupd
- Inherits:
-
ProcessWrapper
- Object
- ProcessWrapper
- Nsqlookupd
- Includes:
- HTTPWrapper
- Defined in:
- lib/nsq-cluster/nsqlookupd.rb
Constant Summary
Constants inherited from ProcessWrapper
ProcessWrapper::HTTPCHECK_INTERVAL
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#http_port ⇒ Object
readonly
Returns the value of attribute http_port.
-
#tcp_port ⇒ Object
readonly
Returns the value of attribute tcp_port.
Attributes inherited from ProcessWrapper
Instance Method Summary collapse
- #args ⇒ Object
-
#channels(topic) ⇒ Object
return a list of all known channels for a topic.
- #command ⇒ Object
-
#delete(params = {}) ⇒ Object
delete a topic or a channel in an existing topic.
-
#info ⇒ Object
returns version number.
-
#initialize(opts = {}, verbose = false) ⇒ Nsqlookupd
constructor
A new instance of Nsqlookupd.
-
#lookup(topic) ⇒ Object
return a list of producers for a topic.
-
#nodes ⇒ Object
return a list of all known nsqd.
-
#ping ⇒ Object
monitoring endpoint.
-
#topics ⇒ Object
return a list of all known topics.
Methods included from HTTPWrapper
Methods inherited from ProcessWrapper
#another_instance_is_running?, #block_until_running, #block_until_stopped, #destroy, #output, #running?, #start, #stop
Constructor Details
#initialize(opts = {}, verbose = false) ⇒ Nsqlookupd
Returns a new instance of Nsqlookupd.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nsq-cluster/nsqlookupd.rb', line 9 def initialize(opts = {}, verbose = false) super @id = opts.delete(:id) || 0 @host = opts.delete(:host) || '127.0.0.1' @tcp_port = opts.delete(:tcp_port) || (4160 + @id * 2) @http_port = opts.delete(:http_port) || (4161 + @id * 2) @broadcast_address = opts.delete(:broadcast_address) || @host @extra_args = opts.map do |key, value| "--#{key.to_s.gsub('_', '-')}=#{value}" end end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
7 8 9 |
# File 'lib/nsq-cluster/nsqlookupd.rb', line 7 def host @host end |
#http_port ⇒ Object (readonly)
Returns the value of attribute http_port.
7 8 9 |
# File 'lib/nsq-cluster/nsqlookupd.rb', line 7 def http_port @http_port end |
#tcp_port ⇒ Object (readonly)
Returns the value of attribute tcp_port.
7 8 9 |
# File 'lib/nsq-cluster/nsqlookupd.rb', line 7 def tcp_port @tcp_port end |
Instance Method Details
#args ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/nsq-cluster/nsqlookupd.rb', line 29 def args [ %Q(--tcp-address=#{@host}:#{@tcp_port}), %Q(--http-address=#{@host}:#{@http_port}), %Q(--broadcast-address=#{@broadcast_address}) ] + @extra_args end |
#channels(topic) ⇒ Object
return a list of all known channels for a topic
51 52 53 |
# File 'lib/nsq-cluster/nsqlookupd.rb', line 51 def channels(topic) get 'channels', topic: topic end |
#command ⇒ Object
24 25 26 |
# File 'lib/nsq-cluster/nsqlookupd.rb', line 24 def command 'nsqlookupd' end |
#delete(params = {}) ⇒ Object
delete a topic or a channel in an existing topic
63 64 65 |
# File 'lib/nsq-cluster/nsqlookupd.rb', line 63 def delete(params = {}) nsqlookupd_post 'delete', topic: params[:topic], channel: params[:channel] end |
#info ⇒ Object
returns version number
75 76 77 |
# File 'lib/nsq-cluster/nsqlookupd.rb', line 75 def info get 'info' end |
#lookup(topic) ⇒ Object
return a list of producers for a topic
39 40 41 |
# File 'lib/nsq-cluster/nsqlookupd.rb', line 39 def lookup(topic) get 'lookup', topic: topic end |
#nodes ⇒ Object
return a list of all known nsqd
57 58 59 |
# File 'lib/nsq-cluster/nsqlookupd.rb', line 57 def nodes get 'nodes' end |
#ping ⇒ Object
monitoring endpoint
69 70 71 |
# File 'lib/nsq-cluster/nsqlookupd.rb', line 69 def ping get 'ping' end |
#topics ⇒ Object
return a list of all known topics
45 46 47 |
# File 'lib/nsq-cluster/nsqlookupd.rb', line 45 def topics get 'topics' end |