Class: Shoryuken::Fetcher
- Inherits:
-
Object
- Object
- Shoryuken::Fetcher
- Includes:
- Util
- Defined in:
- lib/shoryuken/fetcher.rb
Overview
Fetches messages from SQS queues. Handles message retrieval with automatic retry on connectivity errors.
Constant Summary collapse
- FETCH_LIMIT =
Maximum number of messages that can be fetched in a single SQS request
10
Instance Method Summary collapse
-
#fetch(queue, limit) ⇒ Array<Aws::SQS::Types::Message>
Fetches messages from a queue with automatic retry.
-
#initialize(group) ⇒ Fetcher
constructor
Initializes a new Fetcher for a processing group.
Methods included from Util
#elapsed, #fire_event, #logger, #unparse_queues, #worker_name
Constructor Details
#initialize(group) ⇒ Fetcher
Initializes a new Fetcher for a processing group
15 16 17 |
# File 'lib/shoryuken/fetcher.rb', line 15 def initialize(group) @group = group end |
Instance Method Details
#fetch(queue, limit) ⇒ Array<Aws::SQS::Types::Message>
Fetches messages from a queue with automatic retry
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/shoryuken/fetcher.rb', line 24 def fetch(queue, limit) fetch_with_auto_retry(3) do started_at = Time.now logger.debug { "Looking for new messages in #{queue}" } sqs_msgs = Array((queue, limit)) logger.debug { "Found #{sqs_msgs.size} messages for #{queue.name}" } unless sqs_msgs.empty? logger.debug { "Fetcher for #{queue} completed in #{elapsed(started_at)} ms" } sqs_msgs end end |