Class: BBQueue::Producer
- Inherits:
-
Object
- Object
- BBQueue::Producer
- Defined in:
- lib/bbqueue/producer.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#queue_name ⇒ Object
Returns the value of attribute queue_name.
-
#stalking ⇒ Object
Returns the value of attribute stalking.
Instance Method Summary collapse
- #enqueue(object, options = {}) ⇒ Object
-
#initialize(queue_name, options = {}) ⇒ Producer
constructor
A new instance of Producer.
Constructor Details
#initialize(queue_name, options = {}) ⇒ Producer
Returns a new instance of Producer.
6 7 8 9 10 |
# File 'lib/bbqueue/producer.rb', line 6 def initialize(queue_name, = {}) self.queue_name = queue_name self.logger = [:logger] || BBQueue::NullLogger.new self.stalking = Stalking::Producer.new(.merge(:logger => BBQueue::FatalLogger.new(logger))) end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
4 5 6 |
# File 'lib/bbqueue/producer.rb', line 4 def logger @logger end |
#queue_name ⇒ Object
Returns the value of attribute queue_name.
4 5 6 |
# File 'lib/bbqueue/producer.rb', line 4 def queue_name @queue_name end |
#stalking ⇒ Object
Returns the value of attribute stalking.
4 5 6 |
# File 'lib/bbqueue/producer.rb', line 4 def stalking @stalking end |
Instance Method Details
#enqueue(object, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/bbqueue/producer.rb', line 12 def enqueue(object, = {}) logger.info "Enqueue #{object.inspect} with #{.inspect} on #{queue_name.inspect}" obj = BBQueue::Serializer.dump(object) unless stalking.enqueue(queue_name, { "object" => obj }, ) logger.error "Enqueue #{obj.inspect} with #{.inspect} on #{queue_name.inspect} failed" return false end true end |