fluent-plugin-mysql 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 341f3104d55640ff44ceb5440885ec8528a1ce70
4
- data.tar.gz: 4f66da8fa968e4aa78d302e9c2039a2294c966e9
3
+ metadata.gz: 6779a8acd14cbc9c3506aad17847d6bf805b1ba5
4
+ data.tar.gz: b399a06594b6957f4ca308f7fb8c088bf5906835
5
5
  SHA512:
6
- metadata.gz: 227fda4952a521d0529035eed4039d3bb85d1af41b8245d9cf5c5e065d11e982411b56bfacdbc01abd9471f88d9c21e71be70ef9157a820ef847a5088d4008ba
7
- data.tar.gz: 553d05fcd64ffaf61959abe09e45e9f4d4e567ebc69120219c8ead56115281d73dd37121652d5ea3a51aff17e462dc562662fa522177f98ffae35340c63fe28a
6
+ metadata.gz: 53792258fcb40362c7cb913fdac21cd1c6e69db6141120c190b2eda54765542eb72259c062f5f9b10a4beff04a832715fb74e9a4cd4f2003f6931066bb763276
7
+ data.tar.gz: e02269391bf5bbf7ee5b3a27299583ad9b19bf08ef5f75e956567f48997c16f8cd5921a8bc7b8facb0dda24fa21418e2fe214bf6595d2d0116b13c448739563d
data/README.md CHANGED
@@ -27,7 +27,7 @@ on_duplicate_update_keys|on duplicate key update column, comma separator
27
27
 
28
28
  ```
29
29
  <match mysql.input>
30
- type mysql_bulk
30
+ @type mysql_bulk
31
31
  host localhost
32
32
  database test_app_development
33
33
  username root
@@ -68,7 +68,7 @@ INSERT INTO users (id,user_name,created_at,updated_at) VALUES (NULL,'toyama','20
68
68
 
69
69
  ```
70
70
  <match mysql.input>
71
- type mysql_bulk
71
+ @type mysql_bulk
72
72
  host localhost
73
73
  database test_app_development
74
74
  username root
@@ -110,7 +110,7 @@ if duplicate id , update username and updated_at
110
110
 
111
111
  ```
112
112
  <match mysql.input>
113
- type mysql_bulk
113
+ @type mysql_bulk
114
114
  host localhost
115
115
  database test_app_development
116
116
  username root
@@ -1,13 +1,13 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |gem|
3
3
  gem.name = "fluent-plugin-mysql"
4
- gem.version = "0.1.0"
4
+ gem.version = "0.1.1"
5
5
  gem.authors = ["TAGOMORI Satoshi", "Toyama Hiroshi"]
6
6
  gem.email = ["tagomoris@gmail.com", "toyama0919@gmail.com"]
7
7
  gem.description = %q{fluent plugin to insert mysql as json(single column) or insert statement}
8
8
  gem.summary = %q{fluent plugin to insert mysql}
9
9
  gem.homepage = "https://github.com/tagomoris/fluent-plugin-mysql"
10
- gem.license = "APLv2"
10
+ gem.license = "Apache-2.0"
11
11
 
12
12
  gem.files = `git ls-files`.split($\)
13
13
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -20,6 +20,8 @@ module Fluent
20
20
  :desc => <<-DESC
21
21
  Value key names, ${time} is placeholder Time.at(time).strftime("%Y-%m-%d %H:%M:%S").
22
22
  DESC
23
+ config_param :json_key_names, :string, default: nil,
24
+ :desc => "Key names which store data as json"
23
25
  config_param :table, :string,
24
26
  :desc => "Bulk insert table."
25
27
 
@@ -63,6 +65,7 @@ DESC
63
65
 
64
66
  @column_names = @column_names.split(',')
65
67
  @key_names = @key_names.nil? ? @column_names : @key_names.split(',')
68
+ @json_key_names = @json_key_names.split(',') if @json_key_names
66
69
  end
67
70
 
68
71
  def start
@@ -129,6 +132,10 @@ DESC
129
132
  else
130
133
  value = record[key].slice(0, @max_lengths[i])
131
134
  end
135
+
136
+ if @json_key_names && @json_key_names.include?(key)
137
+ value = value.to_json
138
+ end
132
139
  end
133
140
  values << value
134
141
  end
@@ -112,6 +112,18 @@ class MysqlBulkOutputTest < Test::Unit::TestCase
112
112
  on_duplicate_update_keys user_name,updated_at
113
113
  ]
114
114
  end
115
+
116
+ assert_nothing_raised(Fluent::ConfigError) do
117
+ d = create_driver %[
118
+ database test_app_development
119
+ username root
120
+ password hogehoge
121
+ key_names id,url,request_headers,params,created_at,updated_at
122
+ column_names id,url,request_headers_json,params_json,created_date,updated_date
123
+ json_key_names request_headers,params
124
+ table access
125
+ ]
126
+ end
115
127
  end
116
128
 
117
129
  def test_variables
@@ -127,6 +139,7 @@ class MysqlBulkOutputTest < Test::Unit::TestCase
127
139
 
128
140
  assert_equal ['id','user_name','created_at','updated_at'], d.instance.key_names
129
141
  assert_equal ['id','user_name','created_at','updated_at'], d.instance.column_names
142
+ assert_equal nil, d.instance.json_key_names
130
143
  assert_equal " ON DUPLICATE KEY UPDATE user_name = VALUES(user_name),updated_at = VALUES(updated_at)", d.instance.instance_variable_get(:@on_duplicate_key_update_sql)
131
144
 
132
145
  d = create_driver %[
@@ -139,6 +152,7 @@ class MysqlBulkOutputTest < Test::Unit::TestCase
139
152
 
140
153
  assert_equal ['id','user_name','created_at','updated_at'], d.instance.key_names
141
154
  assert_equal ['id','user_name','created_at','updated_at'], d.instance.column_names
155
+ assert_equal nil, d.instance.json_key_names
142
156
  assert_nil d.instance.instance_variable_get(:@on_duplicate_key_update_sql)
143
157
 
144
158
  d = create_driver %[
@@ -152,6 +166,22 @@ class MysqlBulkOutputTest < Test::Unit::TestCase
152
166
 
153
167
  assert_equal ['id','user_name','created_at','updated_at'], d.instance.key_names
154
168
  assert_equal ['id','user','created_date','updated_date'], d.instance.column_names
169
+ assert_equal nil, d.instance.json_key_names
170
+ assert_nil d.instance.instance_variable_get(:@on_duplicate_key_update_sql)
171
+
172
+ d = create_driver %[
173
+ database test_app_development
174
+ username root
175
+ password hogehoge
176
+ key_names id,url,request_headers,params,created_at,updated_at
177
+ column_names id,url,request_headers_json,params_json,created_date,updated_date
178
+ json_key_names request_headers,params
179
+ table access
180
+ ]
181
+
182
+ assert_equal ['id','url','request_headers','params','created_at','updated_at'], d.instance.key_names
183
+ assert_equal ['id','url','request_headers_json','params_json','created_date','updated_date'], d.instance.column_names
184
+ assert_equal ['request_headers','params'], d.instance.json_key_names
155
185
  assert_nil d.instance.instance_variable_get(:@on_duplicate_key_update_sql)
156
186
  end
157
187
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-mysql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - TAGOMORI Satoshi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-01-12 00:00:00.000000000 Z
12
+ date: 2016-03-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
@@ -103,7 +103,7 @@ files:
103
103
  - test/plugin/test_out_mysql_bulk.rb
104
104
  homepage: https://github.com/tagomoris/fluent-plugin-mysql
105
105
  licenses:
106
- - APLv2
106
+ - Apache-2.0
107
107
  metadata: {}
108
108
  post_install_message:
109
109
  rdoc_options: []
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  version: '0'
122
122
  requirements: []
123
123
  rubyforge_project:
124
- rubygems_version: 2.4.3
124
+ rubygems_version: 2.4.8
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: fluent plugin to insert mysql