Class: Droonga::Handler
- Inherits:
-
Object
- Object
- Droonga::Handler
- Includes:
- Pluggable
- Defined in:
- lib/droonga/handler.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#envelope ⇒ Object
readonly
Returns the value of attribute envelope.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #emit(value, name = nil) ⇒ Object
-
#initialize(options = {}) ⇒ Handler
constructor
A new instance of Handler.
- #post(message, destination) ⇒ Object
- #prefer_synchronous?(command) ⇒ Boolean
- #process(envelope) ⇒ Object
- #shutdown ⇒ Object
Methods included from Pluggable
Constructor Details
#initialize(options = {}) ⇒ Handler
Returns a new instance of Handler.
30 31 32 33 34 35 |
# File 'lib/droonga/handler.rb', line 30 def initialize(={}) @options = @name = [:name] @database_name = [:database] prepare end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
28 29 30 |
# File 'lib/droonga/handler.rb', line 28 def context @context end |
#envelope ⇒ Object (readonly)
Returns the value of attribute envelope.
28 29 30 |
# File 'lib/droonga/handler.rb', line 28 def envelope @envelope end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
28 29 30 |
# File 'lib/droonga/handler.rb', line 28 def name @name end |
Instance Method Details
#emit(value, name = nil) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/droonga/handler.rb', line 66 def emit(value, name = nil) unless name if @output_names name = @output_names.first else @output_values = @task["values"] = value return end end @output_values[name] = value end |
#post(message, destination) ⇒ Object
78 79 80 |
# File 'lib/droonga/handler.rb', line 78 def post(, destination) @forwarder.forward(envelope, , destination) end |
#prefer_synchronous?(command) ⇒ Boolean
49 50 51 |
# File 'lib/droonga/handler.rb', line 49 def prefer_synchronous?(command) find_plugin(command).prefer_synchronous?(command) end |
#process(envelope) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/droonga/handler.rb', line 53 def process(envelope) $log.trace("#{log_tag}: process: start") body, command, arguments = parse_envelope(envelope) plugin = find_plugin(command) if plugin.nil? $log.trace("#{log_tag}: process: done: no plugin: <#{command}>") return end process_command(plugin, command, body, arguments) $log.trace("#{log_tag}: process: done: <#{command}>", :plugin => plugin.class) end |
#shutdown ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/droonga/handler.rb', line 37 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 |