fluent-plugin-redis-url-tracker 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MjMwNWM3M2QzZjg0YjNhZDYxNmNkOTlkMGU5ZWYxNTkwNjZjNWU5Nw==
5
+ data.tar.gz: !binary |-
6
+ NmQ5Y2RiMzFmNGM0NmI1YzVjZTgzYmJiOWJlNDM3OWU0MjZjZWMzNg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MTY3YWVlZmQ4ZjRmYWMyOTJjNTU1MjA2ZDlmYWI3YWUyMmMwNTk1NzgwMGRh
10
+ YzczZWFlMWU0YTI0YzQ5Yzc1MDI2MzlkNDA2ZjA3ZjQ5MDZhYzlmZjUwN2Jj
11
+ ZTNlMTM4OWI3Yjg1NWQwNzdkOTY1NzZlMDFkZDk4ZGI0YTEyMDA=
12
+ data.tar.gz: !binary |-
13
+ YzM5ZTFlYzY0NTZiYzUzODJjY2Q0MzVlZmZlYjZhYjRhOTA0NjMwZDJhZTI4
14
+ NDkwZTMyYTJkZGY4NmRhMTg0ODU4NzEzNTAyNzkyNGNmZTc2NTg1MDI3MDI5
15
+ ZjY1ZDdlZDI1MmVkNDAxYzU2Y2JiM2Q3NGIyYmE1ZTQ2MjEwNGY=
@@ -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-url-tracker"
6
+ s.version = "0.2.1"
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Yuki Nishijima", "Kamil Pluta"]
9
+ s.date = %q{2011-09-30}
10
+ s.email = "detfis@gmail.com"
11
+ s.homepage = "http://github.com/detfis/fluent-plugin-redis-url-tracker"
12
+ s.summary = "Redis 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.12.2"]
20
+ s.add_dependency %q<redis>, ["~> 3.1.0"]
21
+ end
@@ -0,0 +1,54 @@
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
+ @db_number = conf.has_key?('db_number') ? conf['db_number'].to_i : nil
18
+
19
+ if conf.has_key?('namespace')
20
+ $log.warn "namespace option has been removed from fluent-plugin-redis 0.1.3. Please add or remove the namespace '#{conf['namespace']}' manually."
21
+ end
22
+ end
23
+
24
+ def start
25
+ super
26
+
27
+ @redis = Redis.new(:host => @host, :port => @port,
28
+ :thread_safe => true, :db => @db_number)
29
+ end
30
+
31
+ def shutdown
32
+ @redis.quit
33
+ end
34
+
35
+ def format(tag, time, record)
36
+ identifier = [tag, time].join(".")
37
+ [identifier, record].to_msgpack
38
+ end
39
+
40
+ def write(chunk)
41
+ @redis.pipelined {
42
+ chunk.open { |io|
43
+ begin
44
+ MessagePack::Unpacker.new(io).each.each { |record|
45
+ @redis.rpush record[1]["url"], record[1].tap{|x| x.delete("url")}
46
+ }
47
+ rescue EOFError
48
+ # EOFError always occured when reached end of chunk.
49
+ end
50
+ }
51
+ }
52
+ end
53
+ end
54
+ 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,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-redis-url-tracker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - Yuki Nishijima
8
+ - Kamil Pluta
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-09-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: fluentd
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: 0.12.2
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: 0.12.2
28
+ - !ruby/object:Gem::Dependency
29
+ name: redis
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 3.1.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: 3.1.0
42
+ description:
43
+ email: detfis@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - CHANGELOG.md
50
+ - Gemfile
51
+ - README.rdoc
52
+ - Rakefile
53
+ - VERSION
54
+ - fluent-plugin-redis.gemspec
55
+ - lib/fluent/plugin/out_redis.rb
56
+ - test/plugin/out_redis.rb
57
+ homepage: http://github.com/detfis/fluent-plugin-redis-url-tracker
58
+ licenses: []
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.2.2
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Redis output plugin for Fluent
80
+ test_files:
81
+ - test/plugin/out_redis.rb