fluent-plugin-droonga 0.0.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +6 -0
  3. data/.yardopts +7 -0
  4. data/Gemfile +14 -2
  5. data/LICENSE.txt +1 -1
  6. data/README.md +1 -1
  7. data/Rakefile +27 -5
  8. data/benchmark/benchmark.rb +1 -1
  9. data/benchmark/utils.rb +9 -6
  10. data/benchmark/watch/benchmark-notify.rb +2 -2
  11. data/benchmark/watch/benchmark-publish.rb +1 -1
  12. data/benchmark/watch/benchmark-scan.rb +1 -1
  13. data/benchmark/watch/catalog.json +1 -1
  14. data/bin/grn2jsons +1 -1
  15. data/fluent-plugin-droonga.gemspec +5 -3
  16. data/lib/droonga/adapter.rb +13 -130
  17. data/lib/droonga/adapter_plugin.rb +51 -0
  18. data/lib/droonga/catalog.rb +2 -2
  19. data/lib/droonga/collector.rb +107 -0
  20. data/lib/droonga/collector_plugin.rb +82 -0
  21. data/lib/droonga/command_mapper.rb +1 -1
  22. data/lib/droonga/{proxy.rb → dispatcher.rb} +116 -151
  23. data/lib/droonga/distributor.rb +51 -0
  24. data/lib/droonga/distributor_plugin.rb +59 -0
  25. data/lib/droonga/engine.rb +9 -50
  26. data/lib/droonga/farm.rb +47 -0
  27. data/lib/droonga/forwarder.rb +125 -0
  28. data/lib/droonga/handler.rb +69 -60
  29. data/lib/droonga/handler_plugin.rb +22 -11
  30. data/lib/droonga/input_message.rb +51 -0
  31. data/lib/droonga/job_queue.rb +5 -1
  32. data/lib/droonga/job_queue_schema.rb +1 -1
  33. data/lib/droonga/logger.rb +1 -1
  34. data/lib/droonga/partition.rb +76 -0
  35. data/lib/droonga/pluggable.rb +62 -0
  36. data/lib/droonga/plugin.rb +18 -16
  37. data/lib/droonga/plugin/{adapter_groonga.rb → adapter/groonga.rb} +10 -10
  38. data/lib/droonga/plugin/adapter/groonga/select.rb +13 -4
  39. data/lib/droonga/plugin/collector/basic.rb +142 -0
  40. data/lib/droonga/plugin/distributor/crud.rb +43 -0
  41. data/lib/droonga/plugin/distributor/groonga.rb +37 -0
  42. data/lib/droonga/plugin/distributor/search.rb +273 -0
  43. data/lib/droonga/plugin/distributor/watch.rb +39 -0
  44. data/lib/droonga/plugin/{handler_add.rb → handler/add.rb} +6 -6
  45. data/lib/droonga/plugin/{handler_forward.rb → handler/forward.rb} +9 -4
  46. data/lib/droonga/plugin/{handler_groonga.rb → handler/groonga.rb} +36 -4
  47. data/lib/droonga/plugin/handler/groonga/column_create.rb +5 -9
  48. data/lib/droonga/plugin/handler/groonga/table_create.rb +9 -18
  49. data/lib/droonga/plugin/{handler_search.rb → handler/search.rb} +4 -4
  50. data/lib/droonga/plugin/{handler_watch.rb → handler/watch.rb} +4 -4
  51. data/lib/droonga/plugin_loader.rb +45 -0
  52. data/lib/droonga/plugin_registerable.rb +51 -0
  53. data/lib/droonga/plugin_repository.rb +56 -0
  54. data/lib/droonga/processor.rb +64 -0
  55. data/lib/droonga/searcher.rb +16 -7
  56. data/lib/droonga/server.rb +5 -9
  57. data/lib/droonga/sweeper.rb +1 -1
  58. data/lib/droonga/watch_schema.rb +1 -1
  59. data/lib/droonga/watcher.rb +1 -1
  60. data/lib/droonga/worker.rb +21 -9
  61. data/lib/fluent/plugin/out_droonga.rb +33 -15
  62. data/lib/groonga_command_converter.rb +1 -1
  63. data/sample/cluster/fluentd.conf +0 -1
  64. data/test/command/config/default/catalog.json +43 -0
  65. data/test/command/config/default/fluentd.conf +11 -0
  66. data/test/command/fixture/documents.jsons +208 -0
  67. data/test/command/fixture/user-table-array.jsons +38 -0
  68. data/test/command/fixture/user-table.jsons +38 -0
  69. data/test/command/run-test.rb +35 -0
  70. data/test/command/suite/add/minimum.expected +12 -0
  71. data/test/command/suite/add/minimum.test +11 -0
  72. data/test/command/suite/add/with-values.expected +12 -0
  73. data/test/command/suite/add/with-values.test +17 -0
  74. data/test/command/suite/add/without-key.expected +12 -0
  75. data/test/command/suite/add/without-key.test +16 -0
  76. data/test/command/suite/groonga/column_create/scalar.expected +34 -0
  77. data/test/command/suite/groonga/column_create/scalar.test +17 -0
  78. data/test/command/suite/groonga/column_create/vector.expected +34 -0
  79. data/test/command/suite/groonga/column_create/vector.test +18 -0
  80. data/test/command/suite/groonga/select/minimum.expected +26 -0
  81. data/test/command/suite/groonga/select/minimum.test +8 -0
  82. data/test/command/suite/groonga/table_create/array.expected +17 -0
  83. data/test/command/suite/groonga/table_create/array.test +8 -0
  84. data/test/command/suite/groonga/table_create/hash.expected +17 -0
  85. data/test/command/suite/groonga/table_create/hash.test +8 -0
  86. data/test/command/suite/search/array-attribute-label.expected +25 -0
  87. data/test/command/suite/search/array-attribute-label.test +30 -0
  88. data/test/command/suite/search/chained-queries.expected +45 -0
  89. data/test/command/suite/search/chained-queries.test +43 -0
  90. data/test/command/suite/search/complex.expected +52 -0
  91. data/test/command/suite/search/complex.test +25 -0
  92. data/test/command/suite/search/condition-nested.expected +19 -0
  93. data/test/command/suite/search/condition-nested.test +29 -0
  94. data/test/command/suite/search/condition-query.expected +28 -0
  95. data/test/command/suite/search/condition-query.test +25 -0
  96. data/test/command/suite/search/condition-script.expected +28 -0
  97. data/test/command/suite/search/condition-script.test +28 -0
  98. data/test/command/suite/search/hash-attribute-label.expected +34 -0
  99. data/test/command/suite/search/hash-attribute-label.test +38 -0
  100. data/test/command/suite/search/minimum.expected +13 -0
  101. data/test/command/suite/search/minimum.test +16 -0
  102. data/test/command/suite/search/multiple-queries.expected +39 -0
  103. data/test/command/suite/search/multiple-queries.test +39 -0
  104. data/test/command/suite/search/output-range.expected +28 -0
  105. data/test/command/suite/search/output-range.test +25 -0
  106. data/test/command/suite/search/simple.expected +52 -0
  107. data/test/command/suite/search/simple.test +24 -0
  108. data/test/command/suite/search/sort-and-output-range.expected +25 -0
  109. data/test/command/suite/search/sort-and-output-range.test +29 -0
  110. data/test/command/suite/search/sort-range.expected +28 -0
  111. data/test/command/suite/search/sort-range.test +28 -0
  112. data/test/command/suite/search/sort-with-invisible-column.expected +28 -0
  113. data/test/command/suite/search/sort-with-invisible-column.test +28 -0
  114. data/test/unit/fixtures/array.grn +18 -0
  115. data/test/{fixtures → unit/fixtures}/catalog.json +0 -0
  116. data/test/{fixtures → unit/fixtures}/document.grn +20 -9
  117. data/test/unit/fixtures/reference/array.grn +11 -0
  118. data/test/unit/fixtures/reference/hash.grn +7 -0
  119. data/test/{helper.rb → unit/helper.rb} +2 -1
  120. data/test/{helper → unit/helper}/fixture.rb +1 -1
  121. data/test/unit/helper/plugin_helper.rb +38 -0
  122. data/test/{helper → unit/helper}/sandbox.rb +19 -6
  123. data/test/{helper → unit/helper}/stub_worker.rb +1 -1
  124. data/test/{helper → unit/helper}/watch_helper.rb +1 -13
  125. data/test/{plugin → unit/plugin}/adapter/groonga/test_select.rb +108 -4
  126. data/test/unit/plugin/collector/test_basic.rb +558 -0
  127. data/test/unit/plugin/distributor/test_search.rb +914 -0
  128. data/test/{plugin → unit/plugin}/handler/groonga/test_column_create.rb +18 -14
  129. data/test/{plugin → unit/plugin}/handler/groonga/test_table_create.rb +13 -11
  130. data/test/{plugin/handler/test_handler_add.rb → unit/plugin/handler/test_add.rb} +2 -14
  131. data/test/{plugin/handler/test_handler_groonga.rb → unit/plugin/handler/test_groonga.rb} +6 -26
  132. data/test/unit/plugin/handler/test_search.rb +601 -0
  133. data/test/{plugin/handler/test_handler_watch.rb → unit/plugin/handler/test_watch.rb} +2 -2
  134. data/test/{run-test.rb → unit/run-test.rb} +3 -3
  135. data/test/{test_adapter.rb → unit/test_adapter.rb} +17 -14
  136. data/test/{test_catalog.rb → unit/test_catalog.rb} +4 -4
  137. data/test/{test_command_mapper.rb → unit/test_command_mapper.rb} +1 -1
  138. data/test/{test_groonga_command_converter.rb → unit/test_groonga_command_converter.rb} +3 -3
  139. data/test/{test_job_queue_schema.rb → unit/test_job_queue_schema.rb} +1 -1
  140. data/test/{test_output.rb → unit/test_output.rb} +9 -9
  141. data/test/{test_handler.rb → unit/test_plugin.rb} +19 -22
  142. data/test/unit/test_plugin_repository.rb +89 -0
  143. data/test/{test_sweeper.rb → unit/test_sweeper.rb} +1 -1
  144. data/test/{test_watch_schema.rb → unit/test_watch_schema.rb} +1 -1
  145. data/test/{test_watcher.rb → unit/test_watcher.rb} +1 -1
  146. metadata +226 -66
  147. data/lib/droonga/executor.rb +0 -289
  148. data/lib/droonga/plugin/handler_proxy.rb +0 -82
  149. data/test/plugin/handler/test_handler_search.rb +0 -512
  150. data/test/test_worker.rb +0 -144
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99aed806731b4f63bdefc707bddd4fb9c6f1d105
4
- data.tar.gz: 0a4ad0ab5c237b44a81656a489744aac4b264a64
3
+ metadata.gz: 16568393cd233c1f8a54d3bce227e328b6e1b293
4
+ data.tar.gz: 48f158466e6f15a069f3f5c8f92add90f740114c
5
5
  SHA512:
6
- metadata.gz: dbeb3a6142fe82e708355ef091ecb2789aa2f18058ac5a9b66089828c91bbfc1237b8f4c5b0998e7fee55a8188f321ac394a547a1608a2e4b15bd6036d24b8e5
7
- data.tar.gz: 1db4e2fe92124dbd2d259dad398fb54868214e339319286ca2ce2c3bd7128b7b76b4cde19b5c6f6f262c6a703142a7a8ebd2b2c80021b381cf024d9c61f558ca
6
+ metadata.gz: aa5bedb70c57916313b56a3639f8567f3a3efc3a43ba9b8bd68fae5d547e91c481ab71865fa1864d9b9cd425f54488acdc60c8cc53d652754b6552ccbe6e1f40
7
+ data.tar.gz: 3a3c6fa0f130808929a5225ea02b5a89bf5b5b850bc2a227cf9a35d54702bb2b63857d136672bc6849455e2de350f7de95c12bdb5dac4313a67785881ad63ef4
data/.gitignore CHANGED
@@ -1 +1,7 @@
1
1
  /Gemfile.lock
2
+ /test/command/.bundle/
3
+ /test/command/Gemfile.lock
4
+ /test/command/bin/
5
+ /test/command/vendor/
6
+ /doc/
7
+ /.yardoc/
@@ -0,0 +1,7 @@
1
+ --output-dir doc/reference/en
2
+ --markup markdown
3
+ --markup-provider kramdown
4
+ lib/**/*.rb
5
+ -
6
+ LICENSE.txt
7
+ doc/text/**/*.*
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 droonga project
1
+ # Copyright (C) 2013 Droonga Project
2
2
  #
3
3
  # This library is free software; you can redistribute it and/or
4
4
  # modify it under the terms of the GNU Lesser General Public
@@ -37,4 +37,16 @@ elsif ENV["TRAVIS"] == "true"
37
37
  end
38
38
  end
39
39
 
40
- gem "droonga-client", github: "droonga/droonga-client-ruby"
40
+ droonga_client_dir = File.join(parent_dir, "droonga-client-ruby")
41
+ if File.exist?(droonga_client_dir)
42
+ gem "droonga-client", :path => droonga_client_dir
43
+ else
44
+ gem "droonga-client", github: "droonga/droonga-client-ruby"
45
+ end
46
+
47
+ drntest_dir = File.join(parent_dir, "drntest")
48
+ if File.exist?(drntest_dir)
49
+ gem "drntest", :path => drntest_dir
50
+ else
51
+ gem "drntest", :github => "droonga/drntest"
52
+ end
@@ -1,4 +1,4 @@
1
- Copyright (C) 2013 droonga project
1
+ Copyright (C) 2013 Droonga Project
2
2
 
3
3
  This library is free software; you can redistribute it and/or
4
4
  modify it under the terms of the GNU Lesser General Public
data/README.md CHANGED
@@ -13,6 +13,6 @@ TODO: Write usage.
13
13
 
14
14
  ## Copyright
15
15
 
16
- * Copyright (c) 2013 droonga project
16
+ * Copyright (c) 2013 Droonga Project
17
17
  * License
18
18
  * GNU Lesser General Public License version 2.1
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- ruby -*-
2
2
  #
3
- # Copyright (C) 2013 droonga project
3
+ # Copyright (C) 2013 Droonga Project
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU Lesser General Public
@@ -15,11 +15,33 @@
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 "bundler/gem_tasks"
18
+ require "bundler/gem_helper"
19
+ require "packnga"
19
20
 
20
- desc "Run test"
21
- task :test do
22
- ruby(File.join(File.dirname(__FILE__), "test", "run-test.rb"))
21
+ base_dir = File.join(File.dirname(__FILE__))
22
+
23
+ helper = Bundler::GemHelper.new(base_dir)
24
+ helper.install
25
+ spec = helper.gemspec
26
+
27
+ Packnga::DocumentTask.new(spec) do |task|
28
+ task.original_language = "en"
29
+ task.translate_languages = ["ja"]
30
+ end
31
+
32
+ namespace :test do
33
+ desc "Run unit test"
34
+ task :unit do
35
+ ruby(File.join(File.dirname(__FILE__), "test", "unit", "run-test.rb"))
36
+ end
37
+
38
+ desc "Run command test"
39
+ task :command do
40
+ ruby(File.join(File.dirname(__FILE__), "test", "command", "run-test.rb"))
41
+ end
23
42
  end
24
43
 
44
+ desc "Run test"
45
+ task :test => ["test:unit", "test:command"]
46
+
25
47
  task :default => :test
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2013 droonga project
3
+ # Copyright (C) 2013 Droonga Project
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU Lesser General Public
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2013 droonga project
3
+ # Copyright (C) 2013 Droonga Project
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU Lesser General Public
@@ -231,12 +231,15 @@ module DroongaBenchmark
231
231
  def start
232
232
  @messages = Queue.new
233
233
  Thread.new do
234
- client = @socket.accept
235
- unpacker = MessagePack::Unpacker.new(client)
236
- unpacker.each do |object|
237
- @messages.push(object)
234
+ loop do
235
+ Thread.new(@socket.accept) do |client|
236
+ unpacker = MessagePack::Unpacker.new(client)
237
+ unpacker.each do |object|
238
+ @messages.push(object)
239
+ end
240
+ client.close
241
+ end
238
242
  end
239
- client.close
240
243
  end
241
244
  end
242
245
  end
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2013 droonga project
3
+ # Copyright (C) 2013 Droonga Project
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU Lesser General Public
@@ -55,7 +55,7 @@ class NotifyBenchmark
55
55
  end
56
56
 
57
57
  notifications = []
58
- while notifications.size != @n_times do
58
+ while notifications.size != @n_times
59
59
  notifications << @receiver.new_message
60
60
  end
61
61
  notifications
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2013 droonga project
3
+ # Copyright (C) 2013 Droonga Project
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU Lesser General Public
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2013 droonga project
3
+ # Copyright (C) 2013 Droonga Project
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU Lesser General Public
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "datasets": {
11
11
  "Watch": {
12
- "workers": 0,
12
+ "workers": 2,
13
13
  "plugins": ["search", "groonga", "add", "watch"],
14
14
  "number_of_replicas": 1,
15
15
  "number_of_partitions": 1,
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- coding: utf-8 -*-
3
3
  #
4
- # Copyright (C) 2013 droonga project
4
+ # Copyright (C) 2013 Droonga Project
5
5
  #
6
6
  # This library is free software; you can redistribute it and/or
7
7
  # modify it under the terms of the GNU Lesser General Public
@@ -1,6 +1,6 @@
1
1
  # -*- mode: ruby; coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2013 droonga project
3
+ # Copyright (C) 2013 Droonga Project
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU Lesser General Public
@@ -17,10 +17,10 @@
17
17
 
18
18
  Gem::Specification.new do |gem|
19
19
  gem.name = "fluent-plugin-droonga"
20
- gem.version = "0.0.2"
20
+ gem.version = "0.7.0"
21
21
  gem.authors = ["Droonga Project"]
22
22
  gem.email = ["droonga@groonga.org"]
23
- gem.description = "Droonga(distributed groonga) plugin for Fluent event collector"
23
+ gem.description = "Droonga(distributed Groonga) plugin for Fluent event collector"
24
24
  gem.summary = gem.description
25
25
  gem.homepage = "https://github.com/droonga/fluent-plugin-droonga"
26
26
  gem.files = `git ls-files`.split($/)
@@ -38,4 +38,6 @@ Gem::Specification.new do |gem|
38
38
  gem.add_development_dependency "test-unit"
39
39
  gem.add_development_dependency "test-unit-notify"
40
40
  gem.add_development_dependency "test-unit-rr"
41
+ gem.add_development_dependency "packnga"
42
+ gem.add_development_dependency "kramdown"
41
43
  end
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2013 droonga project
3
+ # Copyright (C) 2013 Droonga Project
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU Lesser General Public
@@ -15,142 +15,25 @@
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/handler"
18
+ require "droonga/pluggable"
19
+ require "droonga/adapter_plugin"
19
20
 
20
21
  module Droonga
21
- class Adapter < Droonga::Handler
22
- def scatter_all(request, key)
23
- message = [{
24
- "command"=> envelope["type"],
25
- "dataset"=> envelope["dataset"],
26
- "body"=> request,
27
- "key"=> key,
28
- "type"=> "scatter",
29
- "replica"=> "all",
30
- "post"=> true
31
- }]
32
- post(message, "proxy")
33
- end
34
-
35
- def broadcast_all(request)
36
- message = [{
37
- "command"=> envelope["type"],
38
- "dataset"=> envelope["dataset"],
39
- "body"=> request,
40
- "type"=> "broadcast",
41
- "replica"=> "all",
42
- "post"=> true
43
- }]
44
- post(message, "proxy")
45
- end
46
-
47
- def prefer_synchronous?(command)
48
- return true
49
- end
50
- end
51
-
52
- class BasicAdapter < Adapter
53
- Droonga::HandlerPlugin.register("adapter", self)
54
-
55
- command :table_create
56
- def table_create(request)
57
- broadcast_all(request)
58
- end
59
-
60
- command :column_create
61
- def column_create(request)
62
- broadcast_all(request)
63
- end
64
-
65
- command "watch.feed" => :feed
66
- def feed(request)
67
- broadcast_all(request)
68
- end
69
-
70
- command "watch.subscribe" => :subscribe
71
- def subscribe(request)
72
- broadcast_all(request)
73
- end
74
-
75
- command "watch.unsubscribe" => :unsubscribe
76
- def unsubscribe(request)
77
- broadcast_all(request)
78
- end
79
-
80
- command :add
81
- def add(request)
82
- # TODO: update events must be serialized in the primary node of replicas.
83
- key = request["key"] || rand.to_s
84
- scatter_all(request, key)
85
- end
22
+ class Adapter
23
+ include Pluggable
86
24
 
87
- command :update
88
- def update(request)
89
- # TODO: update events must be serialized in the primary node of replicas.
90
- key = request["key"] || rand.to_s
91
- scatter_all(request, key)
25
+ def initialize(dispatcher, options={})
26
+ @dispatcher = dispatcher
27
+ load_plugins(options[:adapters] || [])
92
28
  end
93
29
 
94
- command :reset
95
- def add(request)
96
- # TODO: update events must be serialized in the primary node of replicas.
97
- key = request["key"] || rand.to_s
98
- scatter_all(request, key)
30
+ private
31
+ def instantiate_plugin(name)
32
+ AdapterPlugin.repository.instantiate(name, @dispatcher)
99
33
  end
100
34
 
101
- command :search
102
- def search(request)
103
- message = []
104
- input_names = []
105
- output_names = []
106
- name_mapper = {}
107
- request["queries"].each do |input_name, query|
108
- output = query["output"]
109
- next unless output
110
- input_names << input_name
111
- output_name = input_name + "_reduced"
112
- output_names << output_name
113
- name_mapper[output_name] = input_name
114
- # TODO: offset & limit must be arranged here.
115
- elements = {}
116
- output["elements"].each do |element|
117
- case element
118
- when "count"
119
- elements[element] = ["sum"]
120
- when "records"
121
- # TODO: must take "sortBy" section into account.
122
- elements[element] = ["sort", "<"]
123
- end
124
- end
125
- reducer = {
126
- "inputs"=> [input_name],
127
- "outputs"=> [output_name],
128
- "type"=> "reduce",
129
- "body"=> {
130
- input_name=> {
131
- output_name=> elements
132
- }
133
- }
134
- }
135
- message << reducer
136
- end
137
- gatherer = {
138
- "inputs"=> output_names,
139
- "type"=> "gather",
140
- "body"=> name_mapper,
141
- "post"=> true
142
- }
143
- message << gatherer
144
- searcher = {
145
- "dataset"=> envelope["dataset"] || request["dataset"],
146
- "outputs"=> input_names,
147
- "type"=> "broadcast",
148
- "command"=> "search",
149
- "replica"=> "random",
150
- "body"=> request
151
- }
152
- message.push(searcher)
153
- post(message, "proxy")
35
+ def log_tag
36
+ "adapter"
154
37
  end
155
38
  end
156
39
  end
@@ -0,0 +1,51 @@
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/plugin"
19
+
20
+ module Droonga
21
+ class AdapterPlugin < Plugin
22
+ extend PluginRegisterable
23
+
24
+ def initialize(dispatcher)
25
+ super()
26
+ @dispatcher = dispatcher
27
+ end
28
+
29
+ def add_route(route)
30
+ @dispatcher.add_route(route)
31
+ end
32
+
33
+ def post(body, destination=nil)
34
+ @dispatcher.post(body, destination)
35
+ end
36
+
37
+ def emit(value, name=nil)
38
+ if name
39
+ @output_values[name] = value
40
+ else
41
+ @output_values = value
42
+ end
43
+ end
44
+
45
+ def process(command, message)
46
+ @output_values = {}
47
+ super(command, message)
48
+ post(@output_values) unless @output_values.empty?
49
+ end
50
+ end
51
+ end