fluent-plugin-kestrel 0.1.1 → 0.2.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.
- data/README.rdoc +4 -4
- data/VERSION +1 -1
- data/fluent-plugin-kestrel.gemspec +4 -2
- data/lib/fluent/plugin/in_kestrel.rb +64 -0
- data/lib/fluent/plugin/out_kestrel.rb +1 -3
- data/test/helper.rb +13 -14
- data/test/plugin/test_in_kestrel.rb +39 -0
- data/test/plugin/test_out_kestrel.rb +4 -3
- metadata +5 -3
data/README.rdoc
CHANGED
@@ -16,11 +16,11 @@ see https://github.com/robey/kestrel
|
|
16
16
|
|
17
17
|
<match kestrel.**>
|
18
18
|
type kestrel
|
19
|
+
host localhost # (required) kestrel host
|
20
|
+
queue test # (required) queue name of kestrel
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
port 22133 # optional, default 22133
|
22
|
+
port 22133 # (optional) kestrel port. default 22133
|
23
|
+
ttl 100 # (optional) ttl(sec). default=0 (never expire)
|
24
24
|
</match>
|
25
25
|
|
26
26
|
== Data Format
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "fluent-plugin-kestrel"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Junichiro Takagi"]
|
12
|
-
s.date = "2012-05-
|
12
|
+
s.date = "2012-05-22"
|
13
13
|
s.description = "fluentd output plugin for kestrel queue."
|
14
14
|
s.email = "t.junichiro@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -24,8 +24,10 @@ Gem::Specification.new do |s|
|
|
24
24
|
"Rakefile",
|
25
25
|
"VERSION",
|
26
26
|
"fluent-plugin-kestrel.gemspec",
|
27
|
+
"lib/fluent/plugin/in_kestrel.rb",
|
27
28
|
"lib/fluent/plugin/out_kestrel.rb",
|
28
29
|
"test/helper.rb",
|
30
|
+
"test/plugin/test_in_kestrel.rb",
|
29
31
|
"test/plugin/test_out_kestrel.rb"
|
30
32
|
]
|
31
33
|
s.homepage = "http://github.com/tjun/fluent-plugin-kestrel"
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Fluent
|
2
|
+
class KestrelInput < Input
|
3
|
+
Fluent::Plugin.register_input('kestrel', self)
|
4
|
+
attr_reader :kestrel
|
5
|
+
|
6
|
+
config_param :host, :string, :default => nil
|
7
|
+
config_param :port, :integer, :default => 22133
|
8
|
+
config_param :queue, :string, :default => nil
|
9
|
+
config_param :tag, :string, :default => nil
|
10
|
+
|
11
|
+
config_param :raw, :bool, :default => true
|
12
|
+
config_param :peek, :bool, :default => false
|
13
|
+
config_param :timeout, :integer, :default => 10
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
super
|
17
|
+
require 'kestrel'
|
18
|
+
require 'time'
|
19
|
+
end
|
20
|
+
|
21
|
+
def configure(conf)
|
22
|
+
super
|
23
|
+
|
24
|
+
unless @queue && @host
|
25
|
+
raise ConfigError, "[kestrel config error]:'host' and 'queue' option is required."
|
26
|
+
end
|
27
|
+
unless @tag
|
28
|
+
raise ConfigError, "[kestrel config error]:'tag' option is required."
|
29
|
+
end
|
30
|
+
@timef = TimeFormatter.new(@time_format, @localtime)
|
31
|
+
@options = {
|
32
|
+
:raw => @raw,
|
33
|
+
:peek => @peek,
|
34
|
+
:timeout => @timeout
|
35
|
+
}.freeze
|
36
|
+
end
|
37
|
+
|
38
|
+
def start
|
39
|
+
super
|
40
|
+
|
41
|
+
@kestrel = Kestrel::Client.new(@host + ":" + @port.to_s)
|
42
|
+
@thread = Thread.new(&method(:run))
|
43
|
+
end
|
44
|
+
|
45
|
+
def shutdown
|
46
|
+
@thread.join
|
47
|
+
super
|
48
|
+
end
|
49
|
+
|
50
|
+
def run
|
51
|
+
loop do
|
52
|
+
data = @kestrel.get(@queue, @options)
|
53
|
+
unless data
|
54
|
+
sleep 1
|
55
|
+
else
|
56
|
+
Engine.emit(@tag, Engine.now, data)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
rescue
|
60
|
+
$log.error "unexpected error.", :error=>$!.to_s
|
61
|
+
$log.error_backtrace
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -10,8 +10,6 @@ module Fluent
|
|
10
10
|
config_param :raw, :bool, :default => true
|
11
11
|
config_param :time_format, :string, :default => nil
|
12
12
|
|
13
|
-
|
14
|
-
|
15
13
|
def initialize
|
16
14
|
super
|
17
15
|
require 'kestrel'
|
@@ -22,7 +20,7 @@ module Fluent
|
|
22
20
|
super
|
23
21
|
|
24
22
|
unless @queue && @host
|
25
|
-
raise ConfigError, "[kestrel config error]:'host' and 'queue'
|
23
|
+
raise ConfigError, "[kestrel config error]:'host' and 'queue' option is required."
|
26
24
|
end
|
27
25
|
@timef = TimeFormatter.new(@time_format, @localtime)
|
28
26
|
end
|
data/test/helper.rb
CHANGED
@@ -1,22 +1,10 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
1
3
|
require 'rubygems'
|
2
4
|
require 'bundler'
|
3
|
-
begin
|
4
|
-
Bundler.setup(:default, :development)
|
5
|
-
rescue Bundler::BundlerError => e
|
6
|
-
$stderr.puts e.message
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
-
exit e.status_code
|
9
|
-
end
|
10
5
|
require 'test/unit'
|
11
6
|
require 'shoulda'
|
12
|
-
|
13
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
7
|
require 'fluent/test'
|
16
|
-
require 'fluent/plugin/out_kestrel'
|
17
|
-
|
18
|
-
class Test::Unit::TestCase
|
19
|
-
end
|
20
8
|
|
21
9
|
if ENV['SIMPLE_COV']
|
22
10
|
require 'simplecov'
|
@@ -25,3 +13,14 @@ if ENV['SIMPLE_COV']
|
|
25
13
|
add_filter 'pkg/'
|
26
14
|
end
|
27
15
|
end
|
16
|
+
|
17
|
+
begin
|
18
|
+
Bundler.setup(:default, :development)
|
19
|
+
rescue Bundler::BundlerError => e
|
20
|
+
$stderr.puts e.message
|
21
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
22
|
+
exit e.status_code
|
23
|
+
end
|
24
|
+
|
25
|
+
class Test::Unit::TestCase
|
26
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestFluentPluginInKestrel < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Fluent::Test.setup
|
6
|
+
require 'fluent/plugin/in_kestrel'
|
7
|
+
end
|
8
|
+
|
9
|
+
CONFIG = %[
|
10
|
+
type kestrel
|
11
|
+
host localhost
|
12
|
+
port 22133
|
13
|
+
queue fluent-test
|
14
|
+
tag fluent.test
|
15
|
+
]
|
16
|
+
|
17
|
+
def create_driver(conf = CONFIG)
|
18
|
+
Fluent::Test::InputTestDriver.new(Fluent::KestrelInput).configure(conf)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_configure
|
22
|
+
d = create_driver(%[
|
23
|
+
type kestrel
|
24
|
+
host localhost
|
25
|
+
port 22133
|
26
|
+
queue fluent-test
|
27
|
+
tag fluent.test
|
28
|
+
])
|
29
|
+
|
30
|
+
assert_equal 'localhost', d.instance.host
|
31
|
+
assert_equal 22133, d.instance.port
|
32
|
+
assert_equal "fluent-test", d.instance.queue
|
33
|
+
assert_equal "fluent.test", d.instance.tag
|
34
|
+
end
|
35
|
+
|
36
|
+
# def test_emit
|
37
|
+
# ToDo
|
38
|
+
# end
|
39
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class TestFluentPluginOutKestrel < Test::Unit::TestCase
|
4
4
|
def setup
|
5
5
|
Fluent::Test.setup
|
6
6
|
require 'fluent/plugin/out_kestrel'
|
@@ -28,7 +28,8 @@ class TestFluentPluginKestrel < Test::Unit::TestCase
|
|
28
28
|
assert_equal 'localhost', d.instance.host
|
29
29
|
assert_equal 22133, d.instance.port
|
30
30
|
assert_equal "fluent-test", d.instance.queue
|
31
|
-
|
31
|
+
d.run
|
32
|
+
d.instance.kestrel.flush("fluent-test")
|
32
33
|
end
|
33
34
|
|
34
35
|
def test_format
|
@@ -54,6 +55,6 @@ class TestFluentPluginKestrel < Test::Unit::TestCase
|
|
54
55
|
assert_equal "2011-01-02T13:14:15Z\ttest\t{\"a\":1}", d.instance.kestrel.get("fluent-test", opts=get_opt)
|
55
56
|
assert_equal "2011-01-02T13:14:15Z\ttest\t{\"a\":2}", d.instance.kestrel.get("fluent-test", opts=get_opt)
|
56
57
|
assert_equal "2011-01-02T13:14:15Z\ttest\t{\"a\":3}", d.instance.kestrel.get("fluent-test", opts=get_opt)
|
57
|
-
|
58
|
+
d.instance.kestrel.flush("fluent-test")
|
58
59
|
end
|
59
60
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-kestrel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: kestrel-client
|
@@ -154,8 +154,10 @@ files:
|
|
154
154
|
- Rakefile
|
155
155
|
- VERSION
|
156
156
|
- fluent-plugin-kestrel.gemspec
|
157
|
+
- lib/fluent/plugin/in_kestrel.rb
|
157
158
|
- lib/fluent/plugin/out_kestrel.rb
|
158
159
|
- test/helper.rb
|
160
|
+
- test/plugin/test_in_kestrel.rb
|
159
161
|
- test/plugin/test_out_kestrel.rb
|
160
162
|
homepage: http://github.com/tjun/fluent-plugin-kestrel
|
161
163
|
licenses:
|
@@ -172,7 +174,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
172
174
|
version: '0'
|
173
175
|
segments:
|
174
176
|
- 0
|
175
|
-
hash:
|
177
|
+
hash: -1831959958403091659
|
176
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
179
|
none: false
|
178
180
|
requirements:
|