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.
- checksums.yaml +4 -4
- data/.gitignore +6 -0
- data/.yardopts +7 -0
- data/Gemfile +14 -2
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/Rakefile +27 -5
- data/benchmark/benchmark.rb +1 -1
- data/benchmark/utils.rb +9 -6
- data/benchmark/watch/benchmark-notify.rb +2 -2
- data/benchmark/watch/benchmark-publish.rb +1 -1
- data/benchmark/watch/benchmark-scan.rb +1 -1
- data/benchmark/watch/catalog.json +1 -1
- data/bin/grn2jsons +1 -1
- data/fluent-plugin-droonga.gemspec +5 -3
- data/lib/droonga/adapter.rb +13 -130
- data/lib/droonga/adapter_plugin.rb +51 -0
- data/lib/droonga/catalog.rb +2 -2
- data/lib/droonga/collector.rb +107 -0
- data/lib/droonga/collector_plugin.rb +82 -0
- data/lib/droonga/command_mapper.rb +1 -1
- data/lib/droonga/{proxy.rb → dispatcher.rb} +116 -151
- data/lib/droonga/distributor.rb +51 -0
- data/lib/droonga/distributor_plugin.rb +59 -0
- data/lib/droonga/engine.rb +9 -50
- data/lib/droonga/farm.rb +47 -0
- data/lib/droonga/forwarder.rb +125 -0
- data/lib/droonga/handler.rb +69 -60
- data/lib/droonga/handler_plugin.rb +22 -11
- data/lib/droonga/input_message.rb +51 -0
- data/lib/droonga/job_queue.rb +5 -1
- data/lib/droonga/job_queue_schema.rb +1 -1
- data/lib/droonga/logger.rb +1 -1
- data/lib/droonga/partition.rb +76 -0
- data/lib/droonga/pluggable.rb +62 -0
- data/lib/droonga/plugin.rb +18 -16
- data/lib/droonga/plugin/{adapter_groonga.rb → adapter/groonga.rb} +10 -10
- data/lib/droonga/plugin/adapter/groonga/select.rb +13 -4
- data/lib/droonga/plugin/collector/basic.rb +142 -0
- data/lib/droonga/plugin/distributor/crud.rb +43 -0
- data/lib/droonga/plugin/distributor/groonga.rb +37 -0
- data/lib/droonga/plugin/distributor/search.rb +273 -0
- data/lib/droonga/plugin/distributor/watch.rb +39 -0
- data/lib/droonga/plugin/{handler_add.rb → handler/add.rb} +6 -6
- data/lib/droonga/plugin/{handler_forward.rb → handler/forward.rb} +9 -4
- data/lib/droonga/plugin/{handler_groonga.rb → handler/groonga.rb} +36 -4
- data/lib/droonga/plugin/handler/groonga/column_create.rb +5 -9
- data/lib/droonga/plugin/handler/groonga/table_create.rb +9 -18
- data/lib/droonga/plugin/{handler_search.rb → handler/search.rb} +4 -4
- data/lib/droonga/plugin/{handler_watch.rb → handler/watch.rb} +4 -4
- data/lib/droonga/plugin_loader.rb +45 -0
- data/lib/droonga/plugin_registerable.rb +51 -0
- data/lib/droonga/plugin_repository.rb +56 -0
- data/lib/droonga/processor.rb +64 -0
- data/lib/droonga/searcher.rb +16 -7
- data/lib/droonga/server.rb +5 -9
- data/lib/droonga/sweeper.rb +1 -1
- data/lib/droonga/watch_schema.rb +1 -1
- data/lib/droonga/watcher.rb +1 -1
- data/lib/droonga/worker.rb +21 -9
- data/lib/fluent/plugin/out_droonga.rb +33 -15
- data/lib/groonga_command_converter.rb +1 -1
- data/sample/cluster/fluentd.conf +0 -1
- data/test/command/config/default/catalog.json +43 -0
- data/test/command/config/default/fluentd.conf +11 -0
- data/test/command/fixture/documents.jsons +208 -0
- data/test/command/fixture/user-table-array.jsons +38 -0
- data/test/command/fixture/user-table.jsons +38 -0
- data/test/command/run-test.rb +35 -0
- data/test/command/suite/add/minimum.expected +12 -0
- data/test/command/suite/add/minimum.test +11 -0
- data/test/command/suite/add/with-values.expected +12 -0
- data/test/command/suite/add/with-values.test +17 -0
- data/test/command/suite/add/without-key.expected +12 -0
- data/test/command/suite/add/without-key.test +16 -0
- data/test/command/suite/groonga/column_create/scalar.expected +34 -0
- data/test/command/suite/groonga/column_create/scalar.test +17 -0
- data/test/command/suite/groonga/column_create/vector.expected +34 -0
- data/test/command/suite/groonga/column_create/vector.test +18 -0
- data/test/command/suite/groonga/select/minimum.expected +26 -0
- data/test/command/suite/groonga/select/minimum.test +8 -0
- data/test/command/suite/groonga/table_create/array.expected +17 -0
- data/test/command/suite/groonga/table_create/array.test +8 -0
- data/test/command/suite/groonga/table_create/hash.expected +17 -0
- data/test/command/suite/groonga/table_create/hash.test +8 -0
- data/test/command/suite/search/array-attribute-label.expected +25 -0
- data/test/command/suite/search/array-attribute-label.test +30 -0
- data/test/command/suite/search/chained-queries.expected +45 -0
- data/test/command/suite/search/chained-queries.test +43 -0
- data/test/command/suite/search/complex.expected +52 -0
- data/test/command/suite/search/complex.test +25 -0
- data/test/command/suite/search/condition-nested.expected +19 -0
- data/test/command/suite/search/condition-nested.test +29 -0
- data/test/command/suite/search/condition-query.expected +28 -0
- data/test/command/suite/search/condition-query.test +25 -0
- data/test/command/suite/search/condition-script.expected +28 -0
- data/test/command/suite/search/condition-script.test +28 -0
- data/test/command/suite/search/hash-attribute-label.expected +34 -0
- data/test/command/suite/search/hash-attribute-label.test +38 -0
- data/test/command/suite/search/minimum.expected +13 -0
- data/test/command/suite/search/minimum.test +16 -0
- data/test/command/suite/search/multiple-queries.expected +39 -0
- data/test/command/suite/search/multiple-queries.test +39 -0
- data/test/command/suite/search/output-range.expected +28 -0
- data/test/command/suite/search/output-range.test +25 -0
- data/test/command/suite/search/simple.expected +52 -0
- data/test/command/suite/search/simple.test +24 -0
- data/test/command/suite/search/sort-and-output-range.expected +25 -0
- data/test/command/suite/search/sort-and-output-range.test +29 -0
- data/test/command/suite/search/sort-range.expected +28 -0
- data/test/command/suite/search/sort-range.test +28 -0
- data/test/command/suite/search/sort-with-invisible-column.expected +28 -0
- data/test/command/suite/search/sort-with-invisible-column.test +28 -0
- data/test/unit/fixtures/array.grn +18 -0
- data/test/{fixtures → unit/fixtures}/catalog.json +0 -0
- data/test/{fixtures → unit/fixtures}/document.grn +20 -9
- data/test/unit/fixtures/reference/array.grn +11 -0
- data/test/unit/fixtures/reference/hash.grn +7 -0
- data/test/{helper.rb → unit/helper.rb} +2 -1
- data/test/{helper → unit/helper}/fixture.rb +1 -1
- data/test/unit/helper/plugin_helper.rb +38 -0
- data/test/{helper → unit/helper}/sandbox.rb +19 -6
- data/test/{helper → unit/helper}/stub_worker.rb +1 -1
- data/test/{helper → unit/helper}/watch_helper.rb +1 -13
- data/test/{plugin → unit/plugin}/adapter/groonga/test_select.rb +108 -4
- data/test/unit/plugin/collector/test_basic.rb +558 -0
- data/test/unit/plugin/distributor/test_search.rb +914 -0
- data/test/{plugin → unit/plugin}/handler/groonga/test_column_create.rb +18 -14
- data/test/{plugin → unit/plugin}/handler/groonga/test_table_create.rb +13 -11
- data/test/{plugin/handler/test_handler_add.rb → unit/plugin/handler/test_add.rb} +2 -14
- data/test/{plugin/handler/test_handler_groonga.rb → unit/plugin/handler/test_groonga.rb} +6 -26
- data/test/unit/plugin/handler/test_search.rb +601 -0
- data/test/{plugin/handler/test_handler_watch.rb → unit/plugin/handler/test_watch.rb} +2 -2
- data/test/{run-test.rb → unit/run-test.rb} +3 -3
- data/test/{test_adapter.rb → unit/test_adapter.rb} +17 -14
- data/test/{test_catalog.rb → unit/test_catalog.rb} +4 -4
- data/test/{test_command_mapper.rb → unit/test_command_mapper.rb} +1 -1
- data/test/{test_groonga_command_converter.rb → unit/test_groonga_command_converter.rb} +3 -3
- data/test/{test_job_queue_schema.rb → unit/test_job_queue_schema.rb} +1 -1
- data/test/{test_output.rb → unit/test_output.rb} +9 -9
- data/test/{test_handler.rb → unit/test_plugin.rb} +19 -22
- data/test/unit/test_plugin_repository.rb +89 -0
- data/test/{test_sweeper.rb → unit/test_sweeper.rb} +1 -1
- data/test/{test_watch_schema.rb → unit/test_watch_schema.rb} +1 -1
- data/test/{test_watcher.rb → unit/test_watcher.rb} +1 -1
- metadata +226 -66
- data/lib/droonga/executor.rb +0 -289
- data/lib/droonga/plugin/handler_proxy.rb +0 -82
- data/test/plugin/handler/test_handler_search.rb +0 -512
- data/test/test_worker.rb +0 -144
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16568393cd233c1f8a54d3bce227e328b6e1b293
|
4
|
+
data.tar.gz: 48f158466e6f15a069f3f5c8f92add90f740114c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa5bedb70c57916313b56a3639f8567f3a3efc3a43ba9b8bd68fae5d547e91c481ab71865fa1864d9b9cd425f54488acdc60c8cc53d652754b6552ccbe6e1f40
|
7
|
+
data.tar.gz: 3a3c6fa0f130808929a5225ea02b5a89bf5b5b850bc2a227cf9a35d54702bb2b63857d136672bc6849455e2de350f7de95c12bdb5dac4313a67785881ad63ef4
|
data/.gitignore
CHANGED
data/.yardopts
ADDED
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013
|
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
|
-
|
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
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2013
|
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/
|
18
|
+
require "bundler/gem_helper"
|
19
|
+
require "packnga"
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
data/benchmark/benchmark.rb
CHANGED
data/benchmark/utils.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2013
|
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
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
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
|
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
|
58
|
+
while notifications.size != @n_times
|
59
59
|
notifications << @receiver.new_message
|
60
60
|
end
|
61
61
|
notifications
|
data/bin/grn2jsons
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- mode: ruby; coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2013
|
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
|
20
|
+
gem.version = "0.7.0"
|
21
21
|
gem.authors = ["Droonga Project"]
|
22
22
|
gem.email = ["droonga@groonga.org"]
|
23
|
-
gem.description = "Droonga(distributed
|
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
|
data/lib/droonga/adapter.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2013
|
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/
|
18
|
+
require "droonga/pluggable"
|
19
|
+
require "droonga/adapter_plugin"
|
19
20
|
|
20
21
|
module Droonga
|
21
|
-
class Adapter
|
22
|
-
|
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
|
-
|
88
|
-
|
89
|
-
|
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
|
-
|
95
|
-
def
|
96
|
-
|
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
|
-
|
102
|
-
|
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
|