fluent-plugin-droonga 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -4
  3. data/benchmark/watch/benchmark-notify.rb +2 -2
  4. data/benchmark/watch/benchmark-scan.rb +3 -0
  5. data/benchmark/watch/fluentd.conf +0 -1
  6. data/fluent-plugin-droonga.gemspec +2 -3
  7. data/lib/droonga/catalog.rb +10 -124
  8. data/lib/droonga/catalog/base.rb +140 -0
  9. data/lib/droonga/catalog/version1.rb +23 -0
  10. data/lib/droonga/catalog_loader.rb +33 -0
  11. data/lib/droonga/collector.rb +2 -71
  12. data/lib/droonga/collector_plugin.rb +2 -34
  13. data/lib/droonga/dispatcher.rb +141 -196
  14. data/lib/droonga/distribution_planner.rb +76 -0
  15. data/lib/droonga/distributor.rb +5 -7
  16. data/lib/droonga/distributor_plugin.rb +23 -15
  17. data/lib/droonga/engine.rb +2 -2
  18. data/lib/droonga/event_loop.rb +46 -0
  19. data/lib/droonga/farm.rb +9 -5
  20. data/lib/droonga/fluent_message_sender.rb +84 -0
  21. data/lib/droonga/forwarder.rb +43 -53
  22. data/lib/droonga/handler.rb +20 -68
  23. data/lib/droonga/handler_message.rb +61 -0
  24. data/lib/droonga/handler_messenger.rb +92 -0
  25. data/lib/droonga/handler_plugin.rb +10 -12
  26. data/lib/droonga/input_adapter.rb +52 -0
  27. data/lib/droonga/{adapter.rb → input_adapter_plugin.rb} +7 -13
  28. data/lib/droonga/input_message.rb +11 -11
  29. data/lib/droonga/logger.rb +4 -3
  30. data/lib/droonga/message_pack_packer.rb +62 -0
  31. data/lib/droonga/message_processing_error.rb +54 -0
  32. data/lib/droonga/message_pusher.rb +60 -0
  33. data/lib/droonga/message_receiver.rb +61 -0
  34. data/lib/droonga/output_adapter.rb +53 -0
  35. data/lib/droonga/{adapter_plugin.rb → output_adapter_plugin.rb} +3 -21
  36. data/lib/droonga/output_message.rb +37 -0
  37. data/lib/droonga/partition.rb +27 -5
  38. data/lib/droonga/pluggable.rb +9 -4
  39. data/lib/droonga/plugin.rb +12 -3
  40. data/lib/droonga/plugin/collector/basic.rb +91 -18
  41. data/lib/droonga/plugin/distributor/crud.rb +9 -9
  42. data/lib/droonga/plugin/distributor/distributed_search_planner.rb +401 -0
  43. data/lib/droonga/plugin/distributor/groonga.rb +5 -5
  44. data/lib/droonga/plugin/distributor/search.rb +4 -246
  45. data/lib/droonga/plugin/distributor/watch.rb +11 -6
  46. data/lib/droonga/plugin/handler/add.rb +69 -7
  47. data/lib/droonga/plugin/handler/groonga.rb +6 -6
  48. data/lib/droonga/plugin/handler/search.rb +5 -3
  49. data/lib/droonga/plugin/handler/watch.rb +19 -13
  50. data/lib/droonga/plugin/{adapter → input_adapter}/groonga.rb +5 -11
  51. data/lib/droonga/plugin/{adapter → input_adapter}/groonga/select.rb +2 -36
  52. data/lib/droonga/plugin/output_adapter/groonga.rb +30 -0
  53. data/lib/droonga/plugin/output_adapter/groonga/select.rb +54 -0
  54. data/lib/droonga/plugin_loader.rb +2 -2
  55. data/lib/droonga/processor.rb +21 -23
  56. data/lib/droonga/replier.rb +40 -0
  57. data/lib/droonga/searcher.rb +298 -174
  58. data/lib/droonga/server.rb +0 -67
  59. data/lib/droonga/session.rb +85 -0
  60. data/lib/droonga/test.rb +21 -0
  61. data/lib/droonga/test/stub_distributor.rb +31 -0
  62. data/lib/droonga/test/stub_handler.rb +37 -0
  63. data/lib/droonga/test/stub_handler_message.rb +35 -0
  64. data/lib/droonga/test/stub_handler_messenger.rb +34 -0
  65. data/lib/droonga/time_formatter.rb +37 -0
  66. data/lib/droonga/watcher.rb +1 -0
  67. data/lib/droonga/worker.rb +16 -19
  68. data/lib/fluent/plugin/out_droonga.rb +9 -9
  69. data/lib/groonga_command_converter.rb +5 -5
  70. data/sample/cluster/catalog.json +1 -1
  71. data/test/command/config/default/catalog.json +19 -1
  72. data/test/command/fixture/event.jsons +41 -0
  73. data/test/command/fixture/user-table.jsons +9 -0
  74. data/test/command/run-test.rb +2 -2
  75. data/test/command/suite/add/error/invalid-integer.expected +20 -0
  76. data/test/command/suite/add/error/invalid-integer.test +12 -0
  77. data/test/command/suite/add/error/invalid-time.expected +20 -0
  78. data/test/command/suite/add/error/invalid-time.test +12 -0
  79. data/test/command/suite/add/error/missing-key.expected +13 -0
  80. data/test/command/suite/add/error/missing-key.test +16 -0
  81. data/test/command/suite/add/error/missing-table.expected +13 -0
  82. data/test/command/suite/add/error/missing-table.test +16 -0
  83. data/test/command/suite/add/error/unknown-column.expected +20 -0
  84. data/test/command/suite/add/error/unknown-column.test +12 -0
  85. data/test/command/suite/add/error/unknown-table.expected +13 -0
  86. data/test/command/suite/add/error/unknown-table.test +17 -0
  87. data/test/command/suite/add/minimum.expected +1 -3
  88. data/test/command/suite/add/with-values.expected +1 -3
  89. data/test/command/suite/add/without-key.expected +1 -3
  90. data/test/command/suite/message/error/missing-dataset.expected +13 -0
  91. data/test/command/suite/message/error/missing-dataset.test +5 -0
  92. data/test/command/suite/message/error/unknown-command.expected +13 -0
  93. data/test/command/suite/message/error/unknown-command.test +6 -0
  94. data/test/command/suite/message/error/unknown-dataset.expected +13 -0
  95. data/test/command/suite/message/error/unknown-dataset.test +6 -0
  96. data/test/command/suite/search/{array-attribute-label.expected → attributes/array.expected} +0 -0
  97. data/test/command/suite/search/{array-attribute-label.test → attributes/array.test} +0 -0
  98. data/test/command/suite/search/{hash-attribute-label.expected → attributes/hash.expected} +0 -0
  99. data/test/command/suite/search/{hash-attribute-label.test → attributes/hash.test} +0 -0
  100. data/test/command/suite/search/{condition-nested.expected → condition/nested.expected} +0 -0
  101. data/test/command/suite/search/{condition-nested.test → condition/nested.test} +0 -0
  102. data/test/command/suite/search/{condition-query.expected → condition/query.expected} +0 -0
  103. data/test/command/suite/search/{condition-query.test → condition/query.test} +0 -0
  104. data/test/command/suite/search/{condition-script.expected → condition/script.expected} +0 -0
  105. data/test/command/suite/search/{condition-script.test → condition/script.test} +0 -0
  106. data/test/command/suite/search/error/cyclic-source.expected +18 -0
  107. data/test/command/suite/search/error/cyclic-source.test +12 -0
  108. data/test/command/suite/search/error/deeply-cyclic-source.expected +21 -0
  109. data/test/command/suite/search/error/deeply-cyclic-source.test +15 -0
  110. data/test/command/suite/search/error/missing-source-parameter.expected +17 -0
  111. data/test/command/suite/search/error/missing-source-parameter.test +11 -0
  112. data/test/command/suite/search/error/unknown-source.expected +18 -0
  113. data/test/command/suite/search/error/unknown-source.test +12 -0
  114. data/test/command/suite/search/{minimum.expected → group/count.expected} +2 -1
  115. data/test/command/suite/search/{minimum.test → group/count.test} +5 -3
  116. data/test/command/suite/search/group/limit.expected +19 -0
  117. data/test/command/suite/search/group/limit.test +20 -0
  118. data/test/command/suite/search/group/string.expected +36 -0
  119. data/test/command/suite/search/group/string.test +44 -0
  120. data/test/command/suite/search/{chained-queries.expected → multiple/chained.expected} +0 -0
  121. data/test/command/suite/search/{chained-queries.test → multiple/chained.test} +0 -0
  122. data/test/command/suite/search/{multiple-queries.expected → multiple/parallel.expected} +0 -0
  123. data/test/command/suite/search/{multiple-queries.test → multiple/parallel.test} +0 -0
  124. data/test/command/suite/search/{output-range.expected → range/only-output.expected} +0 -0
  125. data/test/command/suite/search/{output-range.test → range/only-output.test} +0 -0
  126. data/test/command/suite/search/{sort-range.expected → range/only-sort.expected} +0 -0
  127. data/test/command/suite/search/{sort-range.test → range/only-sort.test} +0 -0
  128. data/test/command/suite/search/{sort-and-output-range.expected → range/sort-and-output.expected} +0 -0
  129. data/test/command/suite/search/{sort-and-output-range.test → range/sort-and-output.test} +0 -0
  130. data/test/command/suite/search/range/too-large-output-offset.expected +16 -0
  131. data/test/command/suite/search/range/too-large-output-offset.test +25 -0
  132. data/test/command/suite/search/range/too-large-sort-offset.expected +16 -0
  133. data/test/command/suite/search/range/too-large-sort-offset.test +28 -0
  134. data/test/command/suite/search/response/records/value/time.expected +24 -0
  135. data/test/command/suite/search/response/records/value/time.test +24 -0
  136. data/test/command/suite/search/sort/default-offset-limit.expected +43 -0
  137. data/test/command/suite/search/sort/default-offset-limit.test +26 -0
  138. data/test/command/suite/search/{sort-with-invisible-column.expected → sort/invisible-column.expected} +0 -0
  139. data/test/command/suite/search/{sort-with-invisible-column.test → sort/invisible-column.test} +0 -0
  140. data/test/command/suite/watch/subscribe.expected +12 -0
  141. data/test/command/suite/watch/subscribe.test +9 -0
  142. data/test/command/suite/watch/unsubscribe.expected +12 -0
  143. data/test/command/suite/watch/unsubscribe.test +9 -0
  144. data/test/unit/{test_catalog.rb → catalog/test_version1.rb} +12 -4
  145. data/test/unit/fixtures/{catalog.json → catalog/version1.json} +0 -0
  146. data/test/unit/helper.rb +2 -0
  147. data/test/unit/plugin/collector/test_basic.rb +289 -33
  148. data/test/unit/plugin/distributor/test_search.rb +176 -861
  149. data/test/unit/plugin/distributor/test_search_planner.rb +1102 -0
  150. data/test/unit/plugin/handler/groonga/test_column_create.rb +17 -13
  151. data/test/unit/plugin/handler/groonga/test_table_create.rb +10 -10
  152. data/test/unit/plugin/handler/test_add.rb +74 -11
  153. data/test/unit/plugin/handler/test_groonga.rb +15 -1
  154. data/test/unit/plugin/handler/test_search.rb +33 -17
  155. data/test/unit/plugin/handler/test_watch.rb +43 -27
  156. data/test/unit/run-test.rb +2 -0
  157. data/test/unit/test_message_pack_packer.rb +51 -0
  158. data/test/unit/test_time_formatter.rb +29 -0
  159. metadata +208 -110
  160. data/lib/droonga/job_queue.rb +0 -87
  161. data/lib/droonga/job_queue_schema.rb +0 -65
  162. data/test/unit/test_adapter.rb +0 -51
  163. data/test/unit/test_job_queue_schema.rb +0 -45
@@ -18,6 +18,8 @@
18
18
  require "groonga"
19
19
 
20
20
  require "droonga/forwarder"
21
+ require "droonga/handler_message"
22
+ require "droonga/handler_messenger"
21
23
  require "droonga/pluggable"
22
24
  require "droonga/handler_plugin"
23
25
 
@@ -25,15 +27,22 @@ module Droonga
25
27
  class Handler
26
28
  include Pluggable
27
29
 
28
- attr_reader :context, :envelope, :name
30
+ attr_reader :context, :name
29
31
 
30
- def initialize(options={})
32
+ def initialize(loop, options={})
33
+ @loop = loop
31
34
  @options = options
32
35
  @name = options[:name]
33
36
  @database_name = options[:database]
34
37
  prepare
35
38
  end
36
39
 
40
+ def start
41
+ $log.trace("#{log_tag}: start: start")
42
+ @forwarder.start
43
+ $log.trace("#{log_tag}: start: done")
44
+ end
45
+
37
46
  def shutdown
38
47
  $log.trace("#{log_tag}: shutdown: start")
39
48
  super
@@ -50,96 +59,39 @@ module Droonga
50
59
  find_plugin(command).prefer_synchronous?(command)
51
60
  end
52
61
 
53
- def process(envelope)
62
+ def process(message)
54
63
  $log.trace("#{log_tag}: process: start")
55
- body, command, arguments = parse_envelope(envelope)
64
+ command = message["type"]
56
65
  plugin = find_plugin(command)
57
66
  if plugin.nil?
58
67
  $log.trace("#{log_tag}: process: done: no plugin: <#{command}>")
59
68
  return
60
69
  end
61
- process_command(plugin, command, body, arguments)
70
+ process_command(plugin, command, message)
62
71
  $log.trace("#{log_tag}: process: done: <#{command}>",
63
72
  :plugin => plugin.class)
64
73
  end
65
74
 
66
- def emit(value, name = nil)
67
- unless name
68
- if @output_names
69
- name = @output_names.first
70
- else
71
- @output_values = @task["values"] = value
72
- return
73
- end
74
- end
75
- @output_values[name] = value
76
- end
77
-
78
- def post(message, destination)
79
- @forwarder.forward(envelope, message, destination)
80
- end
81
-
82
75
  private
83
- def parse_envelope(envelope)
84
- @envelope = envelope
85
- envelope["via"] ||= []
86
- [envelope["body"], envelope["type"], envelope["arguments"]]
87
- end
88
-
89
76
  def prepare
90
77
  if @database_name && !@database_name.empty?
91
78
  @context = Groonga::Context.new
92
79
  @database = @context.open_database(@database_name)
93
80
  end
94
81
  load_plugins(@options[:handlers] || [])
95
- @forwarder = Forwarder.new
82
+ @forwarder = Forwarder.new(@loop)
96
83
  end
97
84
 
98
85
  def instantiate_plugin(name)
99
86
  HandlerPlugin.repository.instantiate(name, self)
100
87
  end
101
88
 
102
- def process_command(plugin, command, request, arguments)
103
- return false unless request.is_a? Hash
104
-
105
- @task = request["task"]
106
- return false unless @task.is_a? Hash
107
-
108
- @component = @task["component"]
109
- return false unless @component.is_a? Hash
110
-
111
- @output_values = @task["values"]
112
- @body = @component["body"]
113
- @output_names = @component["outputs"]
114
- @id = request["id"]
115
- @value = request["value"]
116
- @input_name = request["name"]
117
- @descendants = request["descendants"]
89
+ def process_command(plugin, command, raw_message)
90
+ handler_message = HandlerMessage.new(raw_message)
91
+ handler_message.validate
118
92
 
119
- plugin.process(command, @body, *arguments)
120
- output if @descendants
121
- true
122
- end
123
-
124
- def output
125
- result = @task["values"]
126
- if @component["post"]
127
- destination = @component["post"]
128
- destination = envelope["replyTo"] if destination == true
129
- post(result, destination)
130
- end
131
- @descendants.each do |name, dests|
132
- message = {
133
- "id" => @id,
134
- "input" => name,
135
- "value" => result[name]
136
- }
137
- dests.each do |routes|
138
- routes.each do |route|
139
- post(message, "to"=>route, "type"=>"dispatcher")
140
- end
141
- end
142
- end
93
+ messenger = HandlerMessenger.new(@forwarder, handler_message, @options)
94
+ plugin.process(command, handler_message, messenger)
143
95
  end
144
96
 
145
97
  def log_tag
@@ -0,0 +1,61 @@
1
+ # Copyright (C) 2013 Droonga Project
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License version 2.1 as published by the Free Software Foundation.
6
+ #
7
+ # This library is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
+ # Lesser General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU Lesser General Public
13
+ # License along with this library; if not, write to the Free Software
14
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
+
16
+ module Droonga
17
+ class HandlerMessage
18
+ attr_reader :raw
19
+ def initialize(raw)
20
+ @raw = raw
21
+ end
22
+
23
+ def validate
24
+ unless task.is_a?(Hash)
25
+ raise "<task> value isn't object: <#{@raw.inspect}>"
26
+ end
27
+
28
+ unless component.is_a?(Hash)
29
+ raise "<task/component> value isn't object: <#{@raw.inspect}>"
30
+ end
31
+ end
32
+
33
+ def [](name)
34
+ @raw[name]
35
+ end
36
+
37
+ def body
38
+ @body ||= self["body"]
39
+ end
40
+
41
+ def task
42
+ @task ||= body["task"]
43
+ end
44
+
45
+ def component
46
+ @component ||= task["component"]
47
+ end
48
+
49
+ def request
50
+ @request ||= component["body"]
51
+ end
52
+
53
+ def id
54
+ @id ||= body["id"]
55
+ end
56
+
57
+ def descendants
58
+ @descendants ||= body["descendants"]
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,92 @@
1
+ # Copyright (C) 2013 Droonga Project
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License version 2.1 as published by the Free Software Foundation.
6
+ #
7
+ # This library is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
+ # Lesser General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU Lesser General Public
13
+ # License along with this library; if not, write to the Free Software
14
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
+
16
+ require "droonga/replier"
17
+ require "droonga/forwarder"
18
+
19
+ module Droonga
20
+ class HandlerMessenger
21
+ def initialize(forwarder, message, options={})
22
+ @forwarder = forwarder
23
+ @message = message
24
+ @options = options
25
+ @replier = Replier.new(@forwarder)
26
+ @dispatcher = @options[:dispatcher]
27
+ end
28
+
29
+ def emit(value)
30
+ descendants = @message.descendants
31
+ raw_message = @message.raw
32
+ if descendants.empty?
33
+ return if raw_message["replyTo"].nil?
34
+ @replier.reply(raw_message.merge("body" => value))
35
+ else
36
+ descendants.each do |name, dests|
37
+ body = {
38
+ "id" => @message.id,
39
+ "input" => name,
40
+ "value" => value[name],
41
+ }
42
+ dests.each do |dest|
43
+ if @dispatcher
44
+ @dispatcher.dispatch(body, dest)
45
+ else
46
+ message = raw_message.merge("body" => body)
47
+ forward(message, "to" => dest, "type" => "dispatcher")
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ def error(status_code, body)
55
+ descendants = @message.descendants
56
+ raw_message = @message.raw
57
+ if descendants.empty?
58
+ return if raw_message["replyTo"].nil?
59
+ response = raw_message.merge("statusCode" => status_code,
60
+ "body" => body)
61
+ @replier.reply(response)
62
+ else
63
+ #XXX IMPLEMENT ME!!
64
+ raise error
65
+ end
66
+ end
67
+
68
+ # Forwards a Droonga message to other Droonga Engine.
69
+ #
70
+ # @param [Hash] droonga_message
71
+ # The Droonga message to be forwarded.
72
+ # @param [Hash] destination
73
+ # The destination of the Droonga message. See {Forwarder#forward} to
74
+ # know about how to specify destination.
75
+ #
76
+ # @return [void]
77
+ #
78
+ # @see Forwarder#forward
79
+ def forward(droonga_message, destination)
80
+ @forwarder.forward(droonga_message, destination)
81
+ end
82
+
83
+ def inspect
84
+ "\#<#{self.class} id=#{object_id}>"
85
+ end
86
+
87
+ private
88
+ def log_tag
89
+ "[#{Process.ppid}][#{Process.pid}] handler_messenger"
90
+ end
91
+ end
92
+ end
@@ -16,6 +16,7 @@
16
16
  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
17
 
18
18
  require "droonga/plugin"
19
+ require "droonga/message_processing_error"
19
20
 
20
21
  module Droonga
21
22
  class HandlerPlugin < Plugin
@@ -27,20 +28,17 @@ module Droonga
27
28
  @context = @handler.context
28
29
  end
29
30
 
30
- def envelope
31
- @handler.envelope
32
- end
33
-
34
- def emit(value, name=nil)
35
- @handler.emit(value, name)
36
- end
37
-
38
- def post(body, destination=nil)
39
- @handler.post(body, destination)
40
- end
41
-
42
31
  def prefer_synchronous?(command)
43
32
  false
44
33
  end
34
+
35
+ private
36
+ def run_command(command, message, messenger)
37
+ begin
38
+ super
39
+ rescue MessageProcessingError => error
40
+ messenger.error(error.status_code, error.response_body)
41
+ end
42
+ end
45
43
  end
46
44
  end
@@ -0,0 +1,52 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2013 Droonga Project
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License version 2.1 as published by the Free Software Foundation.
8
+ #
9
+ # This library is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # Lesser General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU Lesser General Public
15
+ # License along with this library; if not, write to the Free Software
16
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+
18
+ require "droonga/pluggable"
19
+ require "droonga/input_adapter_plugin"
20
+ require "droonga/input_message"
21
+
22
+ module Droonga
23
+ class InputAdapter
24
+ include Pluggable
25
+
26
+ def initialize(dispatcher, options={})
27
+ @dispatcher = dispatcher
28
+ load_plugins(options[:plugins] || [])
29
+ end
30
+
31
+ def adapt(message)
32
+ adapted_message = message
33
+ @plugins.each do |plugin|
34
+ input_message = InputMessage.new(adapted_message)
35
+ command = input_message.command
36
+ next unless plugin.processable?(command)
37
+ process(command, input_message)
38
+ adapted_message = input_message.adapted_message
39
+ end
40
+ adapted_message
41
+ end
42
+
43
+ private
44
+ def instantiate_plugin(name)
45
+ InputAdapterPlugin.repository.instantiate(name, @dispatcher)
46
+ end
47
+
48
+ def log_tag
49
+ "input-adapter"
50
+ end
51
+ end
52
+ end
@@ -15,25 +15,19 @@
15
15
  # License along with this library; if not, write to the Free Software
16
16
  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
17
 
18
- require "droonga/pluggable"
19
- require "droonga/adapter_plugin"
18
+ require "droonga/plugin"
20
19
 
21
20
  module Droonga
22
- class Adapter
23
- include Pluggable
21
+ class InputAdapterPlugin < Plugin
22
+ extend PluginRegisterable
24
23
 
25
- def initialize(dispatcher, options={})
24
+ def initialize(dispatcher)
25
+ super()
26
26
  @dispatcher = dispatcher
27
- load_plugins(options[:adapters] || [])
28
27
  end
29
28
 
30
- private
31
- def instantiate_plugin(name)
32
- AdapterPlugin.repository.instantiate(name, @dispatcher)
33
- end
34
-
35
- def log_tag
36
- "adapter"
29
+ def forward(message, destination)
30
+ @dispatcher.forward(message, destination)
37
31
  end
38
32
  end
39
33
  end
@@ -17,35 +17,35 @@
17
17
 
18
18
  module Droonga
19
19
  class InputMessage
20
- def initialize(envelope)
21
- @envelope = envelope
20
+ def initialize(raw_message)
21
+ @raw_message = raw_message
22
22
  end
23
23
 
24
- def adapted_envelope
25
- # TODO: We can create adapted envelope non-destructively.
24
+ def adapted_message
25
+ # TODO: We can create adapted message non-destructively.
26
26
  # If it is not performance issue, it is better that we don't
27
- # change envelope destructively. Consider about it later.
28
- @envelope
27
+ # change message destructively. Consider about it later.
28
+ @raw_message
29
29
  end
30
30
 
31
31
  def add_route(route)
32
- @envelope["via"].push(route)
32
+ @raw_message["via"].push(route)
33
33
  end
34
34
 
35
35
  def body
36
- @envelope["body"]
36
+ @raw_message["body"]
37
37
  end
38
38
 
39
39
  def body=(body)
40
- @envelope["body"] = body
40
+ @raw_message["body"] = body
41
41
  end
42
42
 
43
43
  def command
44
- @envelope["type"]
44
+ @raw_message["type"]
45
45
  end
46
46
 
47
47
  def command=(command)
48
- @envelope["type"] = command
48
+ @raw_message["type"] = command
49
49
  end
50
50
  end
51
51
  end