Class: Droonga::HandlerRunner

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of HandlerRunner.



27
28
29
30
31
32
33
34
35
# File 'lib/droonga/handler_runner.rb', line 27

def initialize(loop, options={})
  @loop = loop
  @options = options
  @name = options[:name]
  @label = options[:label]
  @dataset_name = options[:dataset]
  @database_name = options[:database]
  prepare
end

Instance Method Details

#change_schema?(type) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/droonga/handler_runner.rb', line 48

def change_schema?(type)
  find_handler_class(type).action.change_schema?
end

#prefer_synchronous?(type) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/droonga/handler_runner.rb', line 52

def prefer_synchronous?(type)
  find_handler_class(type).action.synchronous?
end

#process(message) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/droonga/handler_runner.rb', line 60

def process(message)
  logger.trace("process: start")
  type = message["type"]
  if type == "database.reopen"
    handler_class = nil
    reopen
  else
    handler_class = find_handler_class(type)
    if handler_class.nil?
      logger.trace("process: done: no handler: <#{type}>")
      return
    end
    process_type(handler_class, type, message)
  end
  logger.trace("process: done: <#{type}>",
               :handler => handler_class)
end

#processable?(type) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/droonga/handler_runner.rb', line 56

def processable?(type)
  not find_handler_class(type).nil?
end

#shutdownObject



42
43
44
45
46
# File 'lib/droonga/handler_runner.rb', line 42

def shutdown
  logger.trace("shutdown: start")
  close_database if @database
  logger.trace("shutdown: done")
end

#startObject



37
38
39
40
# File 'lib/droonga/handler_runner.rb', line 37

def start
  logger.trace("start: start")
  logger.trace("start: done")
end