Sha256: bbc3755c6ef5e46553d6a271b454dd16d2bc398e1c2b87a7ab5850c94339ac63

Contents?: true

Size: 759 Bytes

Versions: 2

Compression:

Stored size: 759 Bytes

Contents

module BBQueue
  class Producer
    attr_accessor :queue_name, :logger, :stalking

    def initialize(queue_name, options = {})
      self.queue_name = queue_name
      self.logger = options[:logger] || BBQueue::NullLogger.new
      self.stalking = Stalking::Producer.new(options.merge(:logger => BBQueue::FatalLogger.new(logger)))
    end

    def enqueue(object, options = {})
      logger.info "Enqueue #{object.inspect} with #{options.inspect} on #{queue_name.inspect}"

      obj = BBQueue::Serializer.dump(object)

      unless stalking.enqueue(queue_name, { "object" => obj }, options)
        logger.error "Enqueue #{obj.inspect} with #{options.inspect} on #{queue_name.inspect} failed"

        return false
      end

      true
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bbqueue-0.0.2 lib/bbqueue/producer.rb
bbqueue-0.0.1 lib/bbqueue/producer.rb