Sha256: a7aaaa118e2151428c1eb63690b558ce32acf4645f47aa6463cadb1e5d0dd7a1

Contents?: true

Size: 977 Bytes

Versions: 1

Compression:

Stored size: 977 Bytes

Contents

require 'aws-sdk'
require 'alephant/logger'

module Alephant
  module Publisher
    module SQSHelper
      class Queue
        WAIT_TIME = 5
        VISABILITY_TIMEOUT = 300

        include Logger

        attr_reader :queue, :timeout, :wait_time, :archiver

        def initialize(queue, archiver, timeout = VISABILITY_TIMEOUT, wait_time = WAIT_TIME)
          @queue     = queue
          @archiver  = archiver
          @timeout   = timeout
          @wait_time = wait_time

          logger.info("Queue#initialize: reading from #{queue.url}")
        end

        def message
          recieve.tap do |m|
            logger.info("Queue#message: received #{m.id}")
            archive m
          end
        end

        def archive(m)
          archiver.see(m)
        end

        def recieve
          queue.receive_message({
            :visibility_timeout => timeout,
            :wait_time_seconds  => wait_time
          })
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alephant-publisher-0.2.6 lib/alephant/publisher/sqs_helper/queue.rb