Class: Droonga::Slice

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/droonga/slice.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options={})
  @dataset = dataset
  @loop = loop
  @options = 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

Parameters:

  • value

    the value to set the attribute on_ready to.



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(message)
  logger.trace("process: start")
  @processor.process(message)
  logger.trace("process: done")
end

#startObject



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_gracefullyObject



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_immediatelyObject



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