Class: Droonga::Slice
- Inherits:
-
Object
- Object
- Droonga::Slice
- Includes:
- Deferrable, Loggable
- Defined in:
- lib/droonga/slice.rb
Instance Method Summary collapse
-
#initialize(label, dataset, loop, options = {}) ⇒ Slice
constructor
A new instance of Slice.
-
#process(message) ⇒ Object
-
#refresh_node_reference ⇒ Object
-
#start ⇒ Object
-
#stop_gracefully ⇒ Object
-
#stop_immediately ⇒ Object
Methods included from Deferrable
Constructor Details
#initialize(label, dataset, loop, options = {}) ⇒ Slice
Returns a new instance of Slice.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/droonga/slice.rb', line 29 def initialize(label, dataset, loop, ={}) @label = label @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 end |
Instance Method Details
#process(message) ⇒ Object
79 80 81 82 83 |
# File 'lib/droonga/slice.rb', line 79 def process() logger.trace("process: start") @processor.process() logger.trace("process: done") end |
#refresh_node_reference ⇒ Object
73 74 75 76 77 |
# File 'lib/droonga/slice.rb', line 73 def refresh_node_reference logger.trace("refresh_node_reference: start") @supervisor.refresh_node_reference if @supervisor logger.trace("refresh_node_reference: done") end |
#start ⇒ Object
41 42 43 44 45 46 |
# File 'lib/droonga/slice.rb', line 41 def start ensure_database @processor.start @job_pusher.start start_supervisor end |
#stop_gracefully ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/droonga/slice.rb', line 48 def stop_gracefully logger.trace("stop_gracefully: start") on_stop = lambda do @job_pusher.shutdown @processor.shutdown yield if block_given? logger.trace("stop_gracefully: done") end if @supervisor @supervisor.stop_gracefully do on_stop.call end else on_stop.call end end |
#stop_immediately ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/droonga/slice.rb', line 65 def stop_immediately logger.trace("stop_immediately: start") @supervisor.stop_immediately if @supervisor @job_pusher.shutdown @processor.shutdown logger.trace("stop_immediately: done") end |