Class: Droonga::Slice

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

Instance Method Summary collapse

Constructor Details

#initialize(loop, options = {}) ⇒ Slice

Returns a new instance of Slice.



29
30
31
32
33
34
35
36
# File 'lib/droonga/slice.rb', line 29

def initialize(loop, options={})
  @options = options
  @n_workers = @options[:n_workers] || 0
  @loop = loop
  @job_pusher = JobPusher.new(@loop, @options[:database])
  @processor = Processor.new(@loop, @job_pusher, @options)
  @supervisor = nil
end

Instance Method Details

#process(message) ⇒ Object



53
54
55
56
57
# File 'lib/droonga/slice.rb', line 53

def process(message)
  logger.trace("process: start")
  @processor.process(message)
  logger.trace("process: done")
end

#shutdownObject



45
46
47
48
49
50
51
# File 'lib/droonga/slice.rb', line 45

def shutdown
  logger.trace("shutdown: start")
  shutdown_supervisor if @supervisor
  @job_pusher.shutdown
  @processor.shutdown
  logger.trace("shutdown: done")
end

#startObject



38
39
40
41
42
43
# File 'lib/droonga/slice.rb', line 38

def start
  ensure_database
  @processor.start
  @job_pusher.start
  start_supervisor if @n_workers > 0
end