fluent-plugin-redislist 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA512:
3
+ metadata.gz: 22ff3d0cba5c5746b17a18e212d6e5870a69e95c4b8910a0a6fc1317d25719b92b816e2c02ab2e6a09b7c0ec520a3c1c027d4ee09dc6152e9e94b913421b14be
4
+ data.tar.gz: 961962f77706c4e6bee86374c782e27c5815b46e8ed60e3e4237229003a86f2752c09fd6637381c10cc2c10f30548f9660734066ba65683f366802e53086b878
5
+ SHA1:
6
+ metadata.gz: 1e7f0cd70098828220d8af2d5d3c89ed85938526
7
+ data.tar.gz: 7e741e319980a9bad05983acb6e349bda396e6e2
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ ## 0.0.1
2
+
3
+ * This initial plugin is released.
4
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-redis-list.gemspec
4
+ gemspec
data/README.rdoc ADDED
@@ -0,0 +1,28 @@
1
+ = Redis list output plugin for Fluent
2
+
3
+ fluent-plugin-redislist is a fluent plugin to output list type to redis.
4
+
5
+ == Installation
6
+
7
+ What you have to do is only installing like this:
8
+
9
+ gem install fluent-plugin-redislist
10
+
11
+ Then fluent automatically loads the plugin installed.
12
+
13
+ == Configuration
14
+
15
+ <match redis.**>
16
+ type redislist
17
+
18
+ host localhost
19
+ port 6379
20
+
21
+ # database number is optional.
22
+ db_number 0 # 0 is default
23
+ </match>
24
+
25
+ == Copyright
26
+
27
+ Copyright:: Copyright (c) 2013- Ken Santou
28
+ License:: Apache License, Version 2.0
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "fluent-plugin-redislist"
6
+ s.version = "0.0.1"
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Ken Santo"]
9
+ s.date = %q{2013-07-16}
10
+ s.email = "kensantou@gmail.com"
11
+ s.homepage = "http://github.com/kensantou/fluent-plugin-redislist"
12
+ s.summary = "Redis list type output plugin for Fluent"
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_dependency %q<fluentd>, ["~> 0.10.0"]
20
+ s.add_dependency %q<redis>, ["~> 2.2.2"]
21
+ end
@@ -0,0 +1,50 @@
1
+ module Fluent
2
+ class RedisOutput < BufferedOutput
3
+ Fluent::Plugin.register_output('redislist', self)
4
+ attr_reader :host, :port, :db_number, :redis
5
+
6
+ def initialize
7
+ super
8
+ require 'redis'
9
+ require 'msgpack'
10
+ end
11
+
12
+ def configure(conf)
13
+ super
14
+
15
+ @host = conf.has_key?('host') ? conf['host'] : 'localhost'
16
+ @port = conf.has_key?('port') ? conf['port'].to_i : 6379
17
+ @db_number = conf.has_key?('db_number') ? conf['db_number'].to_i : nil
18
+
19
+ end
20
+
21
+ def start
22
+ super
23
+
24
+ @redis = Redis.new(:host => @host, :port => @port,
25
+ :thread_safe => true, :db => @db_number)
26
+ end
27
+
28
+ def shutdown
29
+ @redis.quit
30
+ end
31
+
32
+ def format(tag, time, record)
33
+ [tag, record].to_msgpack
34
+ end
35
+
36
+ def write(chunk)
37
+ @redis.pipelined {
38
+ chunk.open { |io|
39
+ begin
40
+ MessagePack::Unpacker.new(io).each.each_with_index { |record, index|
41
+ @redis.rpush record[0], record[1].to_json
42
+ }
43
+ rescue EOFError
44
+ # EOFError always occured when reached end of chunk.
45
+ end
46
+ }
47
+ }
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,39 @@
1
+ require 'fluent/test'
2
+
3
+ class FileOutputTest < Test::Unit::TestCase
4
+ def setup
5
+ Fluent::Test.setup
6
+
7
+ @d = create_driver %[
8
+ host localhost
9
+ port 6379
10
+ db_number 1
11
+ ]
12
+ @time = Time.parse("2011-01-02 13:14:15 UTC").to_i
13
+ end
14
+
15
+ def create_driver(conf = CONFIG)
16
+ Fluent::Test::BufferedOutputTestDriver.new(Fluent::RedisOutput).configure(conf)
17
+ end
18
+
19
+ def test_configure
20
+ assert_equal 'localhost', @d.instance.host
21
+ assert_equal 6379, @d.instance.port
22
+ assert_equal 1, @d.instance.db_number
23
+ end
24
+
25
+ def test_format
26
+ @d.emit({"a"=>1}, @time)
27
+ @d.expect_format(["test.#{@time}", {"a"=>1}].to_msgpack)
28
+ @d.run
29
+ end
30
+
31
+ def test_write
32
+ @d.emit({"a"=>2}, @time)
33
+ @d.emit({"a"=>3}, @time)
34
+ @d.run
35
+
36
+ assert_equal "2", @d.instance.redis.hget("test.#{@time}.0", "a")
37
+ assert_equal "3", @d.instance.redis.hget("test.#{@time}.1", "a")
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-redislist
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ken Santo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2013-07-16 00:00:00 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: fluentd
16
+ prerelease: false
17
+ requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.10.0
22
+ type: :runtime
23
+ version_requirements: *id001
24
+ - !ruby/object:Gem::Dependency
25
+ name: redis
26
+ prerelease: false
27
+ requirement: &id002 !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ~>
30
+ - !ruby/object:Gem::Version
31
+ version: 2.2.2
32
+ type: :runtime
33
+ version_requirements: *id002
34
+ description:
35
+ email: kensantou@gmail.com
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files: []
41
+
42
+ files:
43
+ - CHANGELOG.md
44
+ - Gemfile
45
+ - README.rdoc
46
+ - Rakefile
47
+ - VERSION
48
+ - fluent-plugin-redislist.gemspec
49
+ - lib/fluent/plugin/out_redislist.rb
50
+ - test/plugin/out_redis.rb
51
+ homepage: http://github.com/kensantou/fluent-plugin-redislist
52
+ licenses: []
53
+
54
+ metadata: {}
55
+
56
+ post_install_message:
57
+ rdoc_options: []
58
+
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - &id003
64
+ - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - *id003
70
+ requirements: []
71
+
72
+ rubyforge_project:
73
+ rubygems_version: 2.0.5
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: Redis list type output plugin for Fluent
77
+ test_files:
78
+ - test/plugin/out_redis.rb