Class: Nsqlookupd

Inherits:
ProcessWrapper show all
Includes:
HTTPWrapper
Defined in:
lib/nsq-cluster/nsqlookupd.rb

Constant Summary

Constants inherited from ProcessWrapper

ProcessWrapper::HTTPCHECK_INTERVAL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HTTPWrapper

#get, #post

Methods inherited from ProcessWrapper

#another_instance_is_running?, #block_until_running, #block_until_stopped, #destroy, #output, #running?, #start, #stop

Constructor Details

#initialize(opts = {}) ⇒ Nsqlookupd

Returns a new instance of Nsqlookupd.



9
10
11
12
13
14
15
16
# File 'lib/nsq-cluster/nsqlookupd.rb', line 9

def initialize(opts = {})
  @host = opts[:host] || '127.0.0.1'
  @tcp_port = opts[:tcp_port] || 4160
  @http_port = opts[:http_port] || 4161
  @broadcast_address = opts[:broadcast_address] || @host

  super
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



7
8
9
# File 'lib/nsq-cluster/nsqlookupd.rb', line 7

def host
  @host
end

#http_portObject (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_portObject (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

#argsObject



24
25
26
27
28
29
30
# File 'lib/nsq-cluster/nsqlookupd.rb', line 24

def args
  [
    %Q(--tcp-address=#{@host}:#{@tcp_port}),
    %Q(--http-address=#{@host}:#{@http_port}),
    %Q(--broadcast-address=#{@broadcast_address})
  ]
end

#channels(topic) ⇒ Object

return a list of all known channels for a topic



46
47
48
# File 'lib/nsq-cluster/nsqlookupd.rb', line 46

def channels(topic)
  get 'channels', topic: topic
end

#commandObject



19
20
21
# File 'lib/nsq-cluster/nsqlookupd.rb', line 19

def command
  'nsqlookupd'
end

#delete(params = {}) ⇒ Object

delete a topic or a channel in an existing topic



58
59
60
# File 'lib/nsq-cluster/nsqlookupd.rb', line 58

def delete(params = {})
  nsqlookupd_post 'delete', topic: params[:topic], channel: params[:channel]
end

#infoObject

returns version number



70
71
72
# File 'lib/nsq-cluster/nsqlookupd.rb', line 70

def info
  get 'info'
end

#lookup(topic) ⇒ Object

return a list of producers for a topic



34
35
36
# File 'lib/nsq-cluster/nsqlookupd.rb', line 34

def lookup(topic)
  get 'lookup', topic: topic
end

#nodesObject

return a list of all known nsqd



52
53
54
# File 'lib/nsq-cluster/nsqlookupd.rb', line 52

def nodes
  get 'nodes'
end

#pingObject

monitoring endpoint



64
65
66
# File 'lib/nsq-cluster/nsqlookupd.rb', line 64

def ping
  get 'ping'
end

#topicsObject

return a list of all known topics



40
41
42
# File 'lib/nsq-cluster/nsqlookupd.rb', line 40

def topics
  get 'topics'
end