fluent-plugin-redis-list 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f61b0afc192ab36f4762bbeeb4e8588e107edbe6
4
+ data.tar.gz: f6e7b32add156d204949e61bc089278f37a3c4d1
5
+ SHA512:
6
+ metadata.gz: e67e7c99cab3bcad4a6bebcd052656496515ea5794b1dcdd58a122b017c44471a07a6d3243ee68e67a4b03f8bdc160584aec1a7a413319192ebe810621e425f9
7
+ data.tar.gz: 0ba9b1dd21f7fa1f3910ace5f2828394f0dca32c243240bb977db2b1a28343dde15a910ee5a0ed158142063c1d34218ed91d4161f3324a548c26039f86512740
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
@@ -0,0 +1,20 @@
1
+ ## 0.1.3
2
+
3
+ * Colored the log message added on v0.1.2.
4
+
5
+ ## 0.1.2
6
+
7
+ * Shows a warning message when trying to use namespace option.
8
+
9
+ ## 0.1.1
10
+
11
+ * Disabled Redis::Namespace operation.
12
+
13
+ ## 0.1.0
14
+
15
+ * Specified the versions of dependencies(fluent, redis and redis-namespace).
16
+
17
+ ## 0.0.1
18
+
19
+ * This initial plugin is released.
20
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-redis.gemspec
4
+ gemspec
@@ -0,0 +1,40 @@
1
+ = Redis output plugin for Fluent
2
+
3
+ fluent-plugin-redis is a fluent plugin to output to redis.
4
+
5
+ == Installation
6
+
7
+ What you have to do is only installing like this:
8
+
9
+ gem install fluent-plugin-redis
10
+
11
+ Then fluent automatically loads the plugin installed.
12
+
13
+ == Configuration
14
+
15
+ <match redis.**>
16
+ type redis
17
+
18
+ host localhost
19
+ port 6379
20
+
21
+ # database number is optional.
22
+ db_number 0 # 0 is default
23
+ </match>
24
+
25
+
26
+ == Contributing to fluent-plugin-redis
27
+
28
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
29
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
30
+ * Fork the project
31
+ * Start a feature/bugfix branch
32
+ * Commit and push until you are happy with your contribution
33
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
34
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
35
+
36
+
37
+ == Copyright
38
+
39
+ Copyright:: Copyright (c) 2011- Yuki Nishijima
40
+ License:: Apache License, Version 2.0
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.0
@@ -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-redis-list"
6
+ s.version = "0.0.1"
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Pavel Sutyrin"]
9
+ s.date = %q{2011-09-30}
10
+ s.email = "pavel.sutyrin@gmail.com"
11
+ s.homepage = "https://github.com/spacediver/fluent-plugin-redis"
12
+ s.summary = "Redis output plugin for Fluent (push to list)"
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,56 @@
1
+ module Fluent
2
+ class RedisOutput < BufferedOutput
3
+ Fluent::Plugin.register_output('redis', 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
+ @list = conf.has_key?('list') ? conf['list'] : 'fluentd'
18
+ @db_number = conf.has_key?('db_number') ? conf['db_number'].to_i : nil
19
+
20
+ if conf.has_key?('namespace')
21
+ $log.warn "namespace option has been removed from fluent-plugin-redis 0.1.3. Please add or remove the namespace '#{conf['namespace']}' manually."
22
+ end
23
+ end
24
+
25
+ def start
26
+ super
27
+
28
+ @redis = Redis.new(:host => @host, :port => @port,
29
+ :thread_safe => true, :db => @db_number)
30
+ end
31
+
32
+ def shutdown
33
+ @redis.quit
34
+ end
35
+
36
+ def format(tag, time, record)
37
+ identifier = [tag, time].join(".")
38
+ [identifier, record].to_msgpack
39
+ end
40
+
41
+ def write(chunk)
42
+ @redis.pipelined {
43
+ chunk.open { |io|
44
+ begin
45
+ MessagePack::Unpacker.new(io).each.each_with_index { |record, index|
46
+ @redis.rpush @list record[0]
47
+ @redis.rpush @list record[1]
48
+ }
49
+ rescue EOFError
50
+ # EOFError always occured when reached end of chunk.
51
+ end
52
+ }
53
+ }
54
+ end
55
+ end
56
+ 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,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-redis-list
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Pavel Sutyrin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2011-09-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fluentd
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.10.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.10.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: redis
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.2.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.2.2
41
+ description:
42
+ email: pavel.sutyrin@gmail.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - ".gitignore"
48
+ - CHANGELOG.md
49
+ - Gemfile
50
+ - README.rdoc
51
+ - Rakefile
52
+ - VERSION
53
+ - fluent-plugin-redis.gemspec
54
+ - lib/fluent/plugin/out_redis.rb
55
+ - test/plugin/out_redis.rb
56
+ homepage: https://github.com/spacediver/fluent-plugin-redis
57
+ licenses: []
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 2.5.1
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: Redis output plugin for Fluent (push to list)
79
+ test_files: []