module Jober::QueueBatchFeature::InstanceMethods
Public Instance Methods
execute_batch(batch)
click to toggle source
# File lib/jober/queue_batch.rb, line 42 def execute_batch(batch) perform(batch) rescue Object => ex reschedule_batch(batch) exception(ex) end
run()
click to toggle source
# File lib/jober/queue_batch.rb, line 18 def run cnt = 0 batch = [] while args = pop batch << args if batch.length >= self.class.get_batch_size execute_batch(batch) info { "execute batch #{batch.length}, #{cnt} from #{len}" } batch = [] end break if stopped cnt += 1 end if batch.length > 0 if stopped reschedule_batch(batch) else execute_batch(batch) end end info { "processes total #{cnt} " } self end
Private Instance Methods
reschedule_batch(batch)
click to toggle source
# File lib/jober/queue_batch.rb, line 51 def reschedule_batch(batch) batch.reverse_each { |ev| Jober.redis.lpush(queue_name, Jober.dump(ev)) } end