Class: Droonga::Handler

Inherits:
Object
  • Object
show all
Includes:
Pluggable
Defined in:
lib/droonga/handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Pluggable

#processable?

Constructor Details

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

Returns a new instance of Handler.



32
33
34
35
36
37
38
# File 'lib/droonga/handler.rb', line 32

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

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



30
31
32
# File 'lib/droonga/handler.rb', line 30

def context
  @context
end

#nameObject (readonly)

Returns the value of attribute name.



30
31
32
# File 'lib/droonga/handler.rb', line 30

def name
  @name
end

Instance Method Details

#prefer_synchronous?(command) ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/droonga/handler.rb', line 58

def prefer_synchronous?(command)
  find_plugin(command).prefer_synchronous?(command)
end

#process(message) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/droonga/handler.rb', line 62

def process(message)
  $log.trace("#{log_tag}: process: start")
  command = message["type"]
  plugin = find_plugin(command)
  if plugin.nil?
    $log.trace("#{log_tag}: process: done: no plugin: <#{command}>")
    return
  end
  process_command(plugin, command, message)
  $log.trace("#{log_tag}: process: done: <#{command}>",
             :plugin => plugin.class)
end

#shutdownObject



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/droonga/handler.rb', line 46

def shutdown
  $log.trace("#{log_tag}: shutdown: start")
  super
  @forwarder.shutdown
  if @database
    @database.close
    @context.close
    @database = @context = nil
  end
  $log.trace("#{log_tag}: shutdown: done")
end

#startObject



40
41
42
43
44
# File 'lib/droonga/handler.rb', line 40

def start
  $log.trace("#{log_tag}: start: start")
  @forwarder.start
  $log.trace("#{log_tag}: start: done")
end