Sha256: 01ef084a4fd1227112d22296a0f1decbff329d111dbe6c632e4b44924e5c0fc2

Contents?: true

Size: 660 Bytes

Versions: 1

Compression:

Stored size: 660 Bytes

Contents

require 'aws-sdk-sqs'

module Arthropod
  module Server
    def self.pull(queue_name:, client: nil)
      client ||= Aws::SQS::Client.new

      sender_queue = client.create_queue(queue_name: queue_name)
      response = client.receive_message(queue_url: sender_queue.queue_url, max_number_of_messages: 1, wait_time_seconds: 1)
      response.messages.each do |message|
        request = Arthropod::Request.new(client: client, message: message)
        begin
          request.close(yield request)
        ensure
          client.delete_message(queue_url: sender_queue.queue_url, receipt_handle: message.receipt_handle)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arthropod-0.0.1 lib/arthropod/server.rb