fluent-plugin-mysqlrecord 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: 3676726d67d2335f1c9f60103dafb6e0634184ca
4
+ data.tar.gz: 34aab58badce575907450a69c9f1e38d81a6d354
5
+ SHA512:
6
+ metadata.gz: 8956a05d884d7357b590b8f723554b2d766928c67cafd2659dbbfaf6a8c6a3fc8ccc52bce777c6c74b9f3c52dca7cf76a5c374fede1befbfff6f3181cd714743
7
+ data.tar.gz: 0693f41ebc20e9af056447693e59746896e0e1192e6e747c2584be07c66f842794cb053b7111d441309dd7b83df3a33f8d87d5e5662bf5a8e6bc02eb23032fce
@@ -0,0 +1,25 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ *.gem
16
+ .bundle
17
+ Gemfile.lock
18
+ pkg/*
19
+ # For TextMate, emacs, vim
20
+ *.tmproj
21
+ tmtags
22
+ *~
23
+ \#*
24
+ .\#*
25
+ *.swp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-mysqlrecord.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 polidog
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # fluent-plugin-mysqlrecord
2
+
3
+ 流れてきたデータをそのままinsertするあれ。
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ $ gem install fluent-plugin-mysqlrecord
9
+ ```
10
+
11
+ ## Configuration
12
+
13
+ Format:
14
+
15
+ ```
16
+ <match application.**>
17
+ type forest
18
+ subtype mysqlrecord
19
+ <template>
20
+ host 127.0.0.1
21
+ database table_name
22
+ username root
23
+ password root
24
+ table ${tag_parts[1]}
25
+ flush_interval 5s
26
+ </template>
27
+ </match>
28
+
29
+ ```
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,20 @@
1
+ # coding: utf-8
2
+ Gem::Specification.new do |spec|
3
+ spec.name = "fluent-plugin-mysqlrecord"
4
+ spec.version = "0.0.1"
5
+ spec.authors = ["polidog"]
6
+ spec.email = ["polidogs@gmail.com"]
7
+ spec.summary = %q{test}
8
+ spec.description = %q{test}
9
+ spec.homepage = ""
10
+ spec.license = "MIT"
11
+
12
+ spec.files = `git ls-files -z`.split("\x0")
13
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ["lib"]
16
+
17
+ spec.add_development_dependency "bundler", "~> 1.7"
18
+ spec.add_development_dependency "rake", "~> 10.0"
19
+ spec.add_runtime_dependency "fluentd"
20
+ end
@@ -0,0 +1,59 @@
1
+ module Fluent
2
+
3
+ class MysqlRecordOutput < Fluent::BufferedOutput
4
+ Fluent::Plugin.register_output('mysqlrecord', self)
5
+
6
+ include Fluent::SetTimeKeyMixin
7
+ include Fluent::SetTagKeyMixin
8
+
9
+ config_param :host, :string
10
+ config_param :port, :integer, :default => nil
11
+ config_param :database, :string
12
+ config_param :username, :string
13
+ config_param :password, :string, :default => '', :secret => true
14
+
15
+ config_param :table, :string, :default => nil
16
+
17
+ attr_accessor :handler
18
+
19
+ def initialize
20
+ super
21
+ require 'mysql2-cs-bind'
22
+ end
23
+
24
+ def configure(conf)
25
+ super
26
+ end
27
+
28
+ def start
29
+ super
30
+ end
31
+
32
+ def shutdown
33
+ super
34
+ end
35
+
36
+ def format(tag, time, record)
37
+ [tag, time, record].to_msgpack
38
+ end
39
+
40
+ def client
41
+ Mysql2::Client.new({
42
+ :host => @host, :port => @port,
43
+ :username => @username, :password => @password,
44
+ :database => @database, :flags => Mysql2::Client::MULTI_STATEMENTS,
45
+ })
46
+ end
47
+
48
+ def write(chunk)
49
+ handler = self.client
50
+ chunk.msgpack_each { |tag, time, data|
51
+ cols = data.keys.join(",")
52
+ placeholders = data.map{|k| '?'}.join(',')
53
+ sql = "INSERT INTO #{@table} (#{cols}) VALUES (#{placeholders})"
54
+ handler.xquery(sql, data.values)
55
+ }
56
+ handler.close
57
+ end
58
+ end
59
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-mysqlrecord
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - polidog
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: fluentd
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: test
56
+ email:
57
+ - polidogs@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - fluent-plugin-mysqlrecord.gemspec
68
+ - lib/fluent/plugin/out_mysqlrecord.rb
69
+ homepage: ''
70
+ licenses:
71
+ - MIT
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 2.0.14
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: test
93
+ test_files: []