Sha256: 1eb56e4031600d19e4833b3065b740aa98e15a9e7a96d47883027e345f843fbf

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

require 'queuel/base/queue'
require 'forwardable'
module Queuel
  module SQS
    class Queue < Base::Queue
      extend Forwardable

      attr_accessor :credentials

      def initialize(client, queue_name, credentials={})
        self.client = client
        self.name = queue_name
        self.credentials = credentials
      end


      def push(message, options = {})
        built_message = build_push_message message, options.merge(credentials)
        queue_connection.send_message built_message
      end

      def approximate_number_of_messages
        queue_connection.approximate_number_of_messages
      end

      def size
        approximate_number_of_messages
      end

      private

      def build_new_message(bare_message, options = {})
        message_klass.new(bare_message, credentials)
      end

      def pop_bare_message(options = {})
        queue_connection.receive_message options
      end

      def queue_connection
        @queue_connection ||= client.queues.named(name)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
queuel-0.4.8 lib/queuel/sqs/queue.rb
queuel-0.4.6 lib/queuel/sqs/queue.rb
queuel-0.4.5 lib/queuel/sqs/queue.rb
queuel-0.4.4 lib/queuel/sqs/queue.rb
queuel-0.4.3 lib/queuel/sqs/queue.rb
queuel-0.4.2 lib/queuel/sqs/queue.rb