Sha256: e530700ca1c4c1b5f804578b39f3307064acf6eee61b98758a21b41d280feeaf

Contents?: true

Size: 907 Bytes

Versions: 7

Compression:

Stored size: 907 Bytes

Contents

module Refinery #:nodoc:
  # Mix this module in to classes that want to access a queue.
  module Queueable
    include Loggable
    include Configurable
    # Get a named queue
    def queue(name)
      queue_provider.queue(name)
    end
    
    # Given the queue name and a block, yield the named queue into 
    # the block.
    def with_queue(name, &block)
      begin
        yield queue(name)
      rescue Exception => e
        logger.error "An error occurred when communicating with queue #{name}: #{e}"
        sleep(30)
      end
    end
    
    protected
    # Get the queue provider. Defaults to RightAws::SqsGen2 running
    # in multi-thread mode.
    def queue_provider
      @queue_provider ||= RightAws::SqsGen2.new(
        config['aws']['credentials']["access_key_id"], 
        config['aws']['credentials']["secret_access_key"],
        {:multi_thread => true}
      )
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
aeden-refinery-0.10.5 lib/refinery/queueable.rb
aeden-refinery-0.10.6 lib/refinery/queueable.rb
aeden-refinery-0.10.8 lib/refinery/queueable.rb
refinery-0.10.8 lib/refinery/queueable.rb
refinery-0.10.4 lib/refinery/queueable.rb
refinery-0.10.5 lib/refinery/queueable.rb
refinery-0.10.6 lib/refinery/queueable.rb