fluent-plugin-droonga 0.9.0 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/Gemfile +8 -1
- data/fluent-plugin-droonga.gemspec +2 -2
- data/lib/droonga/adapter.rb +39 -0
- data/lib/droonga/adapter_runner.rb +99 -0
- data/lib/droonga/catalog/base.rb +11 -11
- data/lib/droonga/catalog/dataset.rb +54 -0
- data/lib/droonga/catalog/version1.rb +1 -1
- data/lib/droonga/collector.rb +5 -7
- data/lib/droonga/collector_plugin.rb +7 -7
- data/lib/droonga/command.rb +36 -0
- data/lib/droonga/{plugin/input_adapter/crud.rb → command_repository.rb} +14 -8
- data/lib/droonga/dispatcher.rb +86 -54
- data/lib/droonga/distributed_command_planner.rb +183 -0
- data/lib/droonga/distributor.rb +43 -17
- data/lib/droonga/handler.rb +13 -72
- data/lib/droonga/handler_message.rb +5 -5
- data/lib/droonga/handler_messenger.rb +4 -1
- data/lib/droonga/handler_plugin.rb +2 -2
- data/lib/droonga/handler_runner.rb +104 -0
- data/lib/droonga/input_message.rb +4 -4
- data/lib/droonga/legacy_pluggable.rb +66 -0
- data/lib/droonga/{input_adapter.rb → legacy_plugin.rb} +27 -22
- data/lib/droonga/{plugin_repository.rb → legacy_plugin_repository.rb} +2 -4
- data/lib/droonga/message_matcher.rb +101 -0
- data/lib/droonga/{input_adapter_plugin.rb → planner.rb} +14 -10
- data/lib/droonga/planner_plugin.rb +54 -0
- data/lib/droonga/pluggable.rb +9 -45
- data/lib/droonga/plugin.rb +9 -33
- data/lib/droonga/plugin/collector/basic.rb +2 -0
- data/lib/droonga/plugin/collector/search.rb +31 -37
- data/lib/droonga/plugin/{handler/groonga/table_remove.rb → metadata/adapter_message.rb} +23 -18
- data/lib/droonga/plugin/{handler/search.rb → metadata/handler_action.rb} +19 -15
- data/lib/droonga/plugin/metadata/input_message.rb +39 -0
- data/lib/droonga/plugin/planner/crud.rb +49 -0
- data/lib/droonga/plugin/{distributor → planner}/distributed_search_planner.rb +62 -70
- data/lib/droonga/plugin/{distributor → planner}/groonga.rb +11 -32
- data/lib/droonga/plugin/{distributor → planner}/search.rb +5 -5
- data/lib/droonga/plugin/{distributor → planner}/watch.rb +15 -6
- data/lib/droonga/plugin_loader.rb +10 -0
- data/lib/droonga/plugin_registerable.rb +34 -10
- data/lib/droonga/plugin_registry.rb +58 -0
- data/lib/droonga/plugins/crud.rb +124 -0
- data/lib/droonga/plugins/error.rb +50 -0
- data/lib/droonga/{output_adapter_plugin.rb → plugins/groonga.rb} +9 -13
- data/lib/droonga/plugins/groonga/column_create.rb +123 -0
- data/lib/droonga/plugins/groonga/generic_command.rb +65 -0
- data/lib/droonga/{plugin/output_adapter/groonga.rb → plugins/groonga/generic_response.rb} +16 -15
- data/lib/droonga/plugins/groonga/select.rb +124 -0
- data/lib/droonga/plugins/groonga/table_create.rb +106 -0
- data/lib/droonga/plugins/groonga/table_remove.rb +57 -0
- data/lib/droonga/plugins/search.rb +40 -0
- data/lib/droonga/plugins/watch.rb +156 -0
- data/lib/droonga/processor.rb +8 -10
- data/lib/droonga/searcher.rb +14 -4
- data/lib/droonga/searcher/mecab_filter.rb +67 -0
- data/lib/droonga/session.rb +5 -5
- data/lib/droonga/test.rb +1 -1
- data/lib/droonga/test/stub_handler_message.rb +1 -1
- data/lib/droonga/test/{stub_distributor.rb → stub_planner.rb} +1 -1
- data/lib/droonga/worker.rb +7 -8
- data/lib/fluent/plugin/out_droonga.rb +0 -1
- data/sample/cluster/catalog.json +2 -4
- data/sample/mecab_filter/data.grn +7 -0
- data/sample/mecab_filter/ddl.grn +7 -0
- data/sample/mecab_filter/search_with_mecab_filter.json +21 -0
- data/sample/mecab_filter/search_without_mecab_filter.json +21 -0
- data/test/command/config/default/catalog.json +2 -5
- data/test/command/suite/search/error/no-query.expected +13 -0
- data/test/command/suite/search/error/no-query.test +7 -0
- data/test/command/suite/search/error/unknown-source.expected +26 -0
- data/test/command/suite/watch/subscribe.expected +3 -3
- data/test/command/suite/watch/unsubscribe.expected +3 -3
- data/test/unit/catalog/test_dataset.rb +385 -0
- data/test/unit/catalog/test_version1.rb +111 -45
- data/test/unit/fixtures/catalog/version1.json +0 -3
- data/test/unit/helper.rb +2 -1
- data/test/unit/helper/distributed_search_planner_helper.rb +83 -0
- data/test/unit/plugin/collector/test_basic.rb +233 -376
- data/test/unit/plugin/collector/test_search.rb +8 -17
- data/test/unit/plugin/planner/search_planner/test_basic.rb +120 -0
- data/test/unit/plugin/planner/search_planner/test_group_by.rb +573 -0
- data/test/unit/plugin/planner/search_planner/test_output.rb +388 -0
- data/test/unit/plugin/planner/search_planner/test_sort_by.rb +938 -0
- data/test/unit/plugin/{distributor → planner}/test_search.rb +20 -75
- data/test/unit/{plugin/handler → plugins/crud}/test_add.rb +11 -11
- data/test/unit/plugins/groonga/select/test_adapter_input.rb +213 -0
- data/test/unit/{plugin/output_adapter/groonga/test_select.rb → plugins/groonga/select/test_adapter_output.rb} +12 -13
- data/test/unit/{plugin/handler → plugins}/groonga/test_column_create.rb +20 -5
- data/test/unit/{plugin/handler → plugins}/groonga/test_table_create.rb +5 -0
- data/test/unit/{plugin/handler → plugins}/groonga/test_table_remove.rb +8 -1
- data/test/unit/{plugin/handler → plugins}/test_groonga.rb +5 -5
- data/test/unit/{plugin/handler → plugins}/test_search.rb +21 -5
- data/test/unit/{plugin/handler → plugins}/test_watch.rb +29 -10
- data/{lib/droonga/command_mapper.rb → test/unit/test_command_repository.rb} +16 -22
- data/test/unit/{test_plugin.rb → test_legacy_plugin.rb} +3 -3
- data/test/unit/{test_plugin_repository.rb → test_legacy_plugin_repository.rb} +3 -3
- data/test/unit/test_message_matcher.rb +137 -0
- metadata +86 -66
- data/bin/grn2jsons +0 -82
- data/lib/droonga/distribution_planner.rb +0 -76
- data/lib/droonga/distributor_plugin.rb +0 -95
- data/lib/droonga/output_adapter.rb +0 -53
- data/lib/droonga/plugin/collector/groonga.rb +0 -83
- data/lib/droonga/plugin/distributor/crud.rb +0 -84
- data/lib/droonga/plugin/handler/add.rb +0 -109
- data/lib/droonga/plugin/handler/forward.rb +0 -75
- data/lib/droonga/plugin/handler/groonga.rb +0 -99
- data/lib/droonga/plugin/handler/groonga/column_create.rb +0 -106
- data/lib/droonga/plugin/handler/groonga/table_create.rb +0 -91
- data/lib/droonga/plugin/handler/watch.rb +0 -108
- data/lib/droonga/plugin/input_adapter/groonga.rb +0 -49
- data/lib/droonga/plugin/input_adapter/groonga/select.rb +0 -63
- data/lib/droonga/plugin/output_adapter/crud.rb +0 -51
- data/lib/droonga/plugin/output_adapter/groonga/select.rb +0 -54
- data/lib/groonga_command_converter.rb +0 -143
- data/sample/fluentd.conf +0 -8
- data/test/unit/plugin/distributor/test_search_planner.rb +0 -1102
- data/test/unit/plugin/input_adapter/groonga/test_select.rb +0 -248
- data/test/unit/test_command_mapper.rb +0 -44
- data/test/unit/test_groonga_command_converter.rb +0 -242
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24503ddfa77a2b4c19b83b771069a3c91f738ef2
|
4
|
+
data.tar.gz: 50f89c1a0fed25c58d8d16b5e16c41258cbd4e3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6b1075946a566e9a92703c682a160ece90bfe8e46e7ec2f722617048d25e54b6453aa25ffc91582e12267bd773904d88605b16a20648dc05536f9943bd00e44
|
7
|
+
data.tar.gz: 4140cc01d656daed66444a853ea585c4aec6fc55b10361e29eac617f924b421d2a3aa2fe17519a5c585ffd8d044b55d01e32e76924bb2ed2ecd441af4ae82ed9
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -27,7 +27,7 @@ if File.exist?(local_rroonga_path)
|
|
27
27
|
gem "groonga-command", :path => local_groonga_command_path
|
28
28
|
gem "groonga-command-parser", :path => local_groonga_command_parser_path
|
29
29
|
elsif ENV["TRAVIS"] == "true"
|
30
|
-
require_unreleased_gems =
|
30
|
+
require_unreleased_gems = true
|
31
31
|
if require_unreleased_gems
|
32
32
|
gem "rroonga", :git => "git://github.com/ranguba/rroonga.git"
|
33
33
|
gem "groonga-command",
|
@@ -57,3 +57,10 @@ if File.exist?(drnbench_dir)
|
|
57
57
|
else
|
58
58
|
gem "drnbench", :github => "droonga/drnbench"
|
59
59
|
end
|
60
|
+
|
61
|
+
grn2drn_dir = File.join(parent_dir, "grn2drn")
|
62
|
+
if File.exist?(grn2drn_dir)
|
63
|
+
gem "grn2drn", :path => grn2drn_dir
|
64
|
+
else
|
65
|
+
gem "grn2drn", :github => "droonga/grn2drn"
|
66
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- mode: ruby; coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# Copyright (C) 2013 Droonga Project
|
3
|
+
# Copyright (C) 2013-2014 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,7 +17,7 @@
|
|
17
17
|
|
18
18
|
Gem::Specification.new do |gem|
|
19
19
|
gem.name = "fluent-plugin-droonga"
|
20
|
-
gem.version = "0.9.
|
20
|
+
gem.version = "0.9.9"
|
21
21
|
gem.authors = ["Droonga Project"]
|
22
22
|
gem.email = ["droonga@groonga.org"]
|
23
23
|
gem.description = "Droonga(distributed Groonga) plugin for Fluent event collector"
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright (C) 2014 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/pluggable"
|
17
|
+
require "droonga/plugin/metadata/adapter_message"
|
18
|
+
|
19
|
+
module Droonga
|
20
|
+
class Adapter
|
21
|
+
extend Pluggable
|
22
|
+
|
23
|
+
class << self
|
24
|
+
def message
|
25
|
+
Plugin::Metadata::AdapterMessage.new(self)
|
26
|
+
end
|
27
|
+
|
28
|
+
def id
|
29
|
+
options[:id] || name || object_id.to_s
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def adapt_input(input_message)
|
34
|
+
end
|
35
|
+
|
36
|
+
def adapt_output(output_message)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# Copyright (C) 2013-2014 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/message_matcher"
|
17
|
+
require "droonga/input_message"
|
18
|
+
require "droonga/output_message"
|
19
|
+
require "droonga/adapter"
|
20
|
+
|
21
|
+
module Droonga
|
22
|
+
class AdapterRunner
|
23
|
+
def initialize(dispatcher, plugins)
|
24
|
+
@dispatcher = dispatcher
|
25
|
+
default_plugins = ["error"]
|
26
|
+
plugins += (default_plugins - plugins)
|
27
|
+
@adapter_classes = Adapter.find_sub_classes(plugins)
|
28
|
+
end
|
29
|
+
|
30
|
+
def shutdown
|
31
|
+
end
|
32
|
+
|
33
|
+
def adapt_input(message)
|
34
|
+
$log.trace("#{log_tag}: adapt_input: start",
|
35
|
+
:dataset => message["dataset"],
|
36
|
+
:type => message["type"])
|
37
|
+
adapted_message = message
|
38
|
+
adapted_message["appliedAdapters"] = []
|
39
|
+
@adapter_classes.each do |adapter_class|
|
40
|
+
adapter_class_id = adapter_class.id
|
41
|
+
pattern = adapter_class.message.input_pattern
|
42
|
+
if pattern
|
43
|
+
matcher = MessageMatcher.new(pattern)
|
44
|
+
$log.trace("#{log_tag}: adapt_input: skip: #{adapter_class_id}",
|
45
|
+
:pattern => pattern)
|
46
|
+
next unless matcher.match?(adapted_message)
|
47
|
+
end
|
48
|
+
$log.trace("#{log_tag}: adapt_input: use: #{adapter_class_id}")
|
49
|
+
input_message = InputMessage.new(adapted_message)
|
50
|
+
adapter = adapter_class.new
|
51
|
+
adapter.adapt_input(input_message)
|
52
|
+
adapted_message = input_message.adapted_message
|
53
|
+
adapted_message["appliedAdapters"] << adapter_class_id
|
54
|
+
end
|
55
|
+
$log.trace("#{log_tag}: adapt_input: done",
|
56
|
+
:dataset => adapted_message["dataset"],
|
57
|
+
:type => adapted_message["type"])
|
58
|
+
adapted_message
|
59
|
+
end
|
60
|
+
|
61
|
+
def adapt_output(message)
|
62
|
+
$log.trace("#{log_tag}: adapt_output: start",
|
63
|
+
:dataset => message["dataset"],
|
64
|
+
:type => message["type"])
|
65
|
+
adapted_message = message
|
66
|
+
applied_adapters = adapted_message["appliedAdapters"]
|
67
|
+
@adapter_classes.reverse_each do |adapter_class|
|
68
|
+
adapter_class_id = adapter_class.id
|
69
|
+
if applied_adapters
|
70
|
+
$log.trace("#{log_tag}: adapt_output: skip: #{adapter_class_id}: " +
|
71
|
+
"input adapter wasn't applied",
|
72
|
+
:applied_adapters => applied_adapters)
|
73
|
+
next unless applied_adapters.include?(adapter_class.id)
|
74
|
+
end
|
75
|
+
pattern = adapter_class.message.output_pattern
|
76
|
+
if pattern
|
77
|
+
matcher = MessageMatcher.new(pattern)
|
78
|
+
$log.trace("#{log_tag}: adapt_output: skip: #{adapter_class_id}",
|
79
|
+
:pattern => pattern)
|
80
|
+
next unless matcher.match?(adapted_message)
|
81
|
+
end
|
82
|
+
$log.trace("#{log_tag}: adapt_output: use: #{adapter_class_id}")
|
83
|
+
output_message = OutputMessage.new(adapted_message)
|
84
|
+
adapter = adapter_class.new
|
85
|
+
adapter.adapt_output(output_message)
|
86
|
+
adapted_message = output_message.adapted_message
|
87
|
+
end
|
88
|
+
$log.trace("#{log_tag}: adapt_output: done",
|
89
|
+
:dataset => adapted_message["dataset"],
|
90
|
+
:type => adapted_message["type"])
|
91
|
+
adapted_message
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
def log_tag
|
96
|
+
"adapter-runner"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/lib/droonga/catalog/base.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013 Droonga Project
|
1
|
+
# Copyright (C) 2013-2014 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
|
@@ -20,12 +20,6 @@ require "droonga/message_processing_error"
|
|
20
20
|
module Droonga
|
21
21
|
module Catalog
|
22
22
|
class Base
|
23
|
-
class UnknownDataset < NotFound
|
24
|
-
def initialize(dataset)
|
25
|
-
super("The dataset #{dataset.inspect} does not exist.")
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
23
|
attr_reader :base_path
|
30
24
|
def initialize(data, base_path)
|
31
25
|
@data = data
|
@@ -68,7 +62,7 @@ module Droonga
|
|
68
62
|
options = {
|
69
63
|
:database => path,
|
70
64
|
:n_workers => workers,
|
71
|
-
:
|
65
|
+
:plugins => plugins
|
72
66
|
}
|
73
67
|
results[partition] = options
|
74
68
|
end
|
@@ -114,10 +108,16 @@ module Droonga
|
|
114
108
|
return continuum[max][1]
|
115
109
|
end
|
116
110
|
|
111
|
+
def datasets
|
112
|
+
@data["datasets"] || {}
|
113
|
+
end
|
114
|
+
|
115
|
+
def have_dataset?(name)
|
116
|
+
datasets.key?(name)
|
117
|
+
end
|
118
|
+
|
117
119
|
def dataset(name)
|
118
|
-
|
119
|
-
raise UnknownDataset.new(name) unless dataset
|
120
|
-
dataset
|
120
|
+
datasets[name]
|
121
121
|
end
|
122
122
|
|
123
123
|
def select_range_and_replicas(partition, args, routes)
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Copyright (C) 2013-2014 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 "digest/sha1"
|
17
|
+
|
18
|
+
module Droonga
|
19
|
+
module Catalog
|
20
|
+
class Dataset
|
21
|
+
def initialize(data)
|
22
|
+
@data = data
|
23
|
+
end
|
24
|
+
|
25
|
+
def continuum
|
26
|
+
@continuum ||= compute_continuum
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def compute_continuum
|
31
|
+
number_of_partitions = @data["number_of_partitions"]
|
32
|
+
return [] if number_of_partitions < 2
|
33
|
+
total_weight = compute_total_weight
|
34
|
+
continuum = []
|
35
|
+
@data["ring"].each do |key, value|
|
36
|
+
points = number_of_partitions * 160 * value["weight"] / total_weight
|
37
|
+
points.times do |point|
|
38
|
+
hash = Digest::SHA1.hexdigest("#{key}:#{point}")
|
39
|
+
continuum << [hash[0..7].to_i(16), key]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
continuum.sort do |a, b|
|
43
|
+
a[0] - b[0]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def compute_total_weight
|
48
|
+
@data["ring"].reduce(0) do |result, zone|
|
49
|
+
result + zone[1]["weight"]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/droonga/collector.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Copyright (C) 2013 Droonga Project
|
1
|
+
# Copyright (C) 2013-2014 Droonga Project
|
4
2
|
#
|
5
3
|
# This library is free software; you can redistribute it and/or
|
6
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -15,15 +13,15 @@
|
|
15
13
|
# License along with this library; if not, write to the Free Software
|
16
14
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
15
|
|
18
|
-
require "droonga/
|
16
|
+
require "droonga/legacy_pluggable"
|
19
17
|
require "droonga/collector_plugin"
|
20
18
|
|
21
19
|
module Droonga
|
22
20
|
class Collector
|
23
|
-
include
|
21
|
+
include LegacyPluggable
|
24
22
|
|
25
|
-
def initialize
|
26
|
-
load_plugins(
|
23
|
+
def initialize(plugins)
|
24
|
+
load_plugins(plugins)
|
27
25
|
end
|
28
26
|
|
29
27
|
private
|
@@ -15,13 +15,13 @@
|
|
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/legacy_plugin"
|
19
19
|
|
20
20
|
module Droonga
|
21
|
-
class CollectorPlugin <
|
21
|
+
class CollectorPlugin < LegacyPlugin
|
22
22
|
extend PluginRegisterable
|
23
23
|
|
24
|
-
attr_reader :task, :input_name, :
|
24
|
+
attr_reader :task, :input_name, :step, :output_values, :body, :output_names
|
25
25
|
def initialize
|
26
26
|
super()
|
27
27
|
end
|
@@ -30,11 +30,11 @@ module Droonga
|
|
30
30
|
return false unless message.is_a? Hash
|
31
31
|
@task = message["task"]
|
32
32
|
return false unless @task.is_a? Hash
|
33
|
-
@
|
34
|
-
return false unless @
|
33
|
+
@step = @task["step"]
|
34
|
+
return false unless @step.is_a? Hash
|
35
35
|
@output_values = @task["values"]
|
36
|
-
@body = @
|
37
|
-
@output_names = @
|
36
|
+
@body = @step["body"]
|
37
|
+
@output_names = @step["outputs"]
|
38
38
|
@id = message["id"]
|
39
39
|
@value = message["value"]
|
40
40
|
@input_name = message["name"]
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Copyright (C) 2014 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/message_matcher"
|
17
|
+
|
18
|
+
module Droonga
|
19
|
+
class Command
|
20
|
+
attr_reader :method_name
|
21
|
+
# @option options [Array] :pattern The pattern to be matched
|
22
|
+
# against message. If the pattern is matched to a message,
|
23
|
+
# the command will be applied.
|
24
|
+
#
|
25
|
+
# @see MessageMatcher
|
26
|
+
def initialize(method_name, options)
|
27
|
+
@method_name = method_name
|
28
|
+
@options = options
|
29
|
+
@matcher = MessageMatcher.new(@options[:pattern])
|
30
|
+
end
|
31
|
+
|
32
|
+
def match?(message)
|
33
|
+
@matcher.match?(message)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014 Droonga Project
|
1
|
+
# Copyright (C) 2013-2014 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
|
@@ -13,15 +13,21 @@
|
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
14
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
15
15
|
|
16
|
-
require "droonga/input_adapter_plugin"
|
17
|
-
|
18
16
|
module Droonga
|
19
|
-
class
|
20
|
-
|
17
|
+
class CommandRepository
|
18
|
+
attr_reader :commands
|
19
|
+
def initialize
|
20
|
+
@commands = []
|
21
|
+
end
|
22
|
+
|
23
|
+
def register(command)
|
24
|
+
@commands << command
|
25
|
+
end
|
21
26
|
|
22
|
-
|
23
|
-
|
24
|
-
|
27
|
+
def find(message)
|
28
|
+
@commands.find do |command|
|
29
|
+
command.match?(message)
|
30
|
+
end
|
25
31
|
end
|
26
32
|
end
|
27
33
|
end
|