Class: Shoryuken::Fetcher

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/shoryuken/fetcher.rb

Constant Summary collapse

FETCH_LIMIT =
10

Instance Method Summary collapse

Methods included from Util

#elapsed, #fire_event, #logger, #unparse_queues, #worker_name

Constructor Details

#initialize(group) ⇒ Fetcher

Returns a new instance of Fetcher.


7
8
9
# File 'lib/shoryuken/fetcher.rb', line 7

def initialize(group)
  @group = group
end

Instance Method Details

#fetch(queue, limit) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/shoryuken/fetcher.rb', line 11

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(receive_messages(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