lib/upperkut/processor.rb in upperkut-0.1.2 vs lib/upperkut/processor.rb in upperkut-0.1.3
- old
+ new
@@ -1,8 +1,7 @@
module Upperkut
class Processor
-
def initialize(manager)
@manager = manager
@worker = @manager.worker
@sleeping_time = 0
end
@@ -10,12 +9,13 @@
def run
@thread ||= Thread.new do
process
end
end
+
def kill
- return if !@thread
+ return unless @thread
@thread.raise Upperkut::Shutdown
end
private
@@ -33,25 +33,23 @@
def should_process?
buffer_size = @worker.size
return false if @manager.stopped
- return false if buffer_size == 0
+ return false if buffer_size.zero?
# TODO: rename #setup by config
buffer_size >= @worker.setup.batch_size ||
@sleeping_time >= @worker.setup.max_wait
end
def process_batch
- begin
- @sleeping_time = 0
- @worker.new.process
- rescue Exception => ex
- # Add to retry_queue
- # if retry_limit is reached
- # send to dead
- raise ex
- end
+ @sleeping_time = 0
+ @worker.new.process
+ rescue Exception => ex
+ # Add to retry_queue
+ # if retry_limit is reached
+ # send to dead
+ raise ex
end
end
end