Class: Nsqcd::Queue

Inherits:
Object
  • Object
show all
Defined in:
lib/nsqcd/queue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, opts) ⇒ Queue

Returns a new instance of Queue.



4
5
6
7
8
# File 'lib/nsqcd/queue.rb', line 4

def initialize(name, opts)
  @name = name
  @opts = opts
  @handler_klass = Nsqcd::CONFIG[:handler]
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/nsqcd/queue.rb', line 2

def name
  @name
end

#optsObject (readonly)

Returns the value of attribute opts.



2
3
4
# File 'lib/nsqcd/queue.rb', line 2

def opts
  @opts
end

#topicObject (readonly)

Returns the value of attribute topic.



2
3
4
# File 'lib/nsqcd/queue.rb', line 2

def topic
  @topic
end

Instance Method Details

#publish(topic, msg) ⇒ Object



10
11
12
13
# File 'lib/nsqcd/queue.rb', line 10

def publish(topic, msg)
  producer = Nsq::Producer.new(@opts[:nsqlookupd], topic)
  producer.write(msg)
end