Class: MailHandler::SQS::Client
- Inherits:
-
Object
- Object
- MailHandler::SQS::Client
- Defined in:
- lib/interfaces/sqs.rb
Overview
Yields an interface to a specific sqs queue
Instance Attribute Summary collapse
-
#queues ⇒ Object
Returns the value of attribute queues.
Instance Method Summary collapse
- #fetch_messages ⇒ Object
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(config) ⇒ Client
Returns a new instance of Client.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/interfaces/sqs.rb', line 19 def initialize(config) all_queues = ::AWS::SQS.new( access_key_id: config[:access_key_id], secret_access_key: config[:secret_access_key], region: config[:aws_region] ).queues @queues = config[:sqs_queues].map do |queue_name| all_queues.named queue_name end @batch_size = config[:batch_size] || 1 end |
Instance Attribute Details
#queues ⇒ Object
Returns the value of attribute queues.
17 18 19 |
# File 'lib/interfaces/sqs.rb', line 17 def queues @queues end |
Instance Method Details
#fetch_messages ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/interfaces/sqs.rb', line 33 def [ @queues.map do |queue| queue.(limit: @batch_size) end ].flatten.compact end |