Class: Droonga::Processor
- Inherits:
-
Object
- Object
- Droonga::Processor
- Includes:
- Loggable
- Defined in:
- lib/droonga/processor.rb
Instance Method Summary collapse
-
#initialize(loop, job_pusher, options = {}) ⇒ Processor
constructor
A new instance of Processor.
- #process(message) ⇒ Object
- #shutdown ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(loop, job_pusher, options = {}) ⇒ Processor
Returns a new instance of Processor.
23 24 25 26 27 28 |
# File 'lib/droonga/processor.rb', line 23 def initialize(loop, job_pusher, ={}) @loop = loop @job_pusher = job_pusher @options = @n_workers = @options[:n_workers] || 0 end |
Instance Method Details
#process(message) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/droonga/processor.rb', line 41 def process() logger.trace("process: start") type = ["type"] if @handler_runner.processable?(type) logger.trace("process: handlable: #{type}") synchronous = @handler_runner.prefer_synchronous?(type) change_schema = @handler_runner.change_schema?(type) if @n_workers.zero? or synchronous or change_schema @handler_runner.process() if change_schema @job_pusher.broadcast() end else @job_pusher.push() end else logger.trace("process: ignore #{type}") end logger.trace("process: done") end |
#shutdown ⇒ Object
35 36 37 38 39 |
# File 'lib/droonga/processor.rb', line 35 def shutdown logger.trace("shutdown: start") @handler_runner.shutdown logger.trace("shutdown: done") end |
#start ⇒ Object
30 31 32 33 |
# File 'lib/droonga/processor.rb', line 30 def start @handler_runner = HandlerRunner.new(@loop, @options) @handler_runner.start end |