Class: Shoryuken::Fetcher
- Inherits:
-
Object
- Object
- Shoryuken::Fetcher
- 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
Instance Method Details
#fetch(queue, available_processors) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/shoryuken/fetcher.rb', line 7 def fetch(queue, available_processors) started_at = Time.now logger.debug { "Looking for new messages in '#{queue}'" } begin limit = available_processors > FETCH_LIMIT ? FETCH_LIMIT : available_processors sqs_msgs = Array((queue, limit)) logger.info { "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 rescue => ex logger.error { "Error fetching message: #{ex}" } logger.error { ex.backtrace.first } [] end end |