Class: Upperkut::BatchExecution
- Inherits:
-
Object
- Object
- Upperkut::BatchExecution
- Includes:
- Util
- Defined in:
- lib/upperkut/batch_execution.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(worker, logger = Upperkut::Logging.logger) ⇒ BatchExecution
constructor
A new instance of BatchExecution.
Methods included from Util
#decode_json_items, #encode_json_items, #to_underscore
Constructor Details
#initialize(worker, logger = Upperkut::Logging.logger) ⇒ BatchExecution
Returns a new instance of BatchExecution.
7 8 9 10 |
# File 'lib/upperkut/batch_execution.rb', line 7 def initialize(worker, logger = Upperkut::Logging.logger) @worker = worker @logger = logger end |
Instance Method Details
#execute ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/upperkut/batch_execution.rb', line 12 def execute worker_instance = @worker.new items = @worker.fetch_items.freeze items_body = items.collect do |item| item['body'] end @worker.server_middlewares.invoke(@worker, items) do worker_instance.perform(items_body.dup) end rescue Exception => ex @worker.push_items(items_body) @logger.info( action: :requeue, ex: ex, item_size: items_body.size ) @logger.error(ex.backtrace.join("\n")) raise ex end |