Class: Droonga::Slice
Instance Attribute Summary collapse
-
#on_ready ⇒ Object
writeonly
Sets the attribute on_ready.
Instance Method Summary collapse
-
#initialize(dataset, loop, options = {}) ⇒ Slice
constructor
A new instance of Slice.
- #process(message) ⇒ Object
- #start ⇒ Object
- #stop_gracefully ⇒ Object
- #stop_immediately ⇒ Object
Constructor Details
#initialize(dataset, loop, options = {}) ⇒ Slice
Returns a new instance of Slice.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/droonga/slice.rb', line 28 def initialize(dataset, loop, ={}) @dataset = dataset @loop = loop @options = @n_workers = @options[:n_workers] || 0 @database_path = @options[:database] @job_pusher = JobPusher.new(@loop, @database_path) @processor = Processor.new(@loop, @job_pusher, @options) @supervisor = nil @on_ready = nil end |
Instance Attribute Details
#on_ready=(value) ⇒ Object
Sets the attribute on_ready
27 28 29 |
# File 'lib/droonga/slice.rb', line 27 def on_ready=(value) @on_ready = value end |
Instance Method Details
#process(message) ⇒ Object
72 73 74 75 76 |
# File 'lib/droonga/slice.rb', line 72 def process() logger.trace("process: start") @processor.process() logger.trace("process: done") end |
#start ⇒ Object
40 41 42 43 44 45 |
# File 'lib/droonga/slice.rb', line 40 def start ensure_database @processor.start @job_pusher.start start_supervisor end |
#stop_gracefully ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/droonga/slice.rb', line 47 def stop_gracefully logger.trace("stop_gracefully: start") on_stop = lambda do @job_pusher.shutdown @processor.shutdown yield if block_given? end if @supervisor @supervisor.stop_gracefully do on_stop.call end else on_stop.call end logger.trace("stop_gracefully: done") end |
#stop_immediately ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/droonga/slice.rb', line 64 def stop_immediately logger.trace("stop_immediately: start") @supervisor.stop_immediately if @supervisor @job_pusher.shutdown @processor.shutdown logger.trace("stop_immediately: done") end |