fluent-plugin-sql 0.4.4 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/README.md +2 -2
- data/VERSION +1 -1
- data/fluent-plugin-sql.gemspec +1 -1
- data/lib/fluent/plugin/in_sql.rb +28 -3
- data/lib/fluent/plugin/out_sql.rb +20 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d602eab48f2e5a82afd2805ea57198d5517bb1b7
|
4
|
+
data.tar.gz: fec9b91b4f26b49f9f8262adbf86e0a29b6b9c6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e3909a2229451959f1ce21d69febb6ca102dae935da5944feb9895510f655fa0349b4f9b737bfdeba02533de55f7ac4dffab32f7cfe1e8beb80bb40864aa600
|
7
|
+
data.tar.gz: 82ec1c90fc5b4a0436a20235f2839d892a94eef18e3154823526b322a1f0547f0fe0b3019538b9e07a9b473e0b0581af65471452e3ec905524c21c94c5cdd4fd
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -30,7 +30,7 @@ It stores last selected rows to a file (named *state\_file*) to not forget the l
|
|
30
30
|
## Input: Configuration
|
31
31
|
|
32
32
|
<source>
|
33
|
-
type sql
|
33
|
+
@type sql
|
34
34
|
|
35
35
|
host rdb_host
|
36
36
|
database rdb_database
|
@@ -96,7 +96,7 @@ This plugin takes advantage of ActiveRecord underneath. For `host`, `port`, `dat
|
|
96
96
|
## Output: Configuration
|
97
97
|
|
98
98
|
<match my.rdb.*>
|
99
|
-
type sql
|
99
|
+
@type sql
|
100
100
|
host rdb_host
|
101
101
|
port 3306
|
102
102
|
database rdb_database
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/fluent-plugin-sql.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.require_paths = ['lib']
|
18
18
|
gem.license = "Apache-2.0"
|
19
19
|
|
20
|
-
gem.add_dependency "fluentd", [">= 0.
|
20
|
+
gem.add_dependency "fluentd", [">= 0.12.17", "< 2"]
|
21
21
|
gem.add_dependency 'activerecord', "~> 4.2"
|
22
22
|
gem.add_dependency 'activerecord-import', "~> 0.7"
|
23
23
|
gem.add_development_dependency "rake", ">= 0.9.2"
|
data/lib/fluent/plugin/in_sql.rb
CHANGED
@@ -22,17 +22,36 @@ module Fluent
|
|
22
22
|
class SQLInput < Input
|
23
23
|
Plugin.register_input('sql', self)
|
24
24
|
|
25
|
+
# For fluentd v0.12.16 or earlier
|
26
|
+
class << self
|
27
|
+
unless method_defined?(:desc)
|
28
|
+
def desc(description)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
desc 'RDBMS host'
|
25
34
|
config_param :host, :string
|
35
|
+
desc 'RDBMS port'
|
26
36
|
config_param :port, :integer, :default => nil
|
37
|
+
desc 'RDBMS driver name.'
|
27
38
|
config_param :adapter, :string
|
39
|
+
desc 'RDBMS database name'
|
28
40
|
config_param :database, :string
|
41
|
+
desc 'RDBMS login user name'
|
29
42
|
config_param :username, :string, :default => nil
|
43
|
+
desc 'RDBMS login password'
|
30
44
|
config_param :password, :string, :default => nil, :secret => true
|
45
|
+
desc 'RDBMS socket path'
|
31
46
|
config_param :socket, :string, :default => nil
|
32
47
|
|
48
|
+
desc 'path to a file to store last rows'
|
33
49
|
config_param :state_file, :string, :default => nil
|
50
|
+
desc 'prefix of tags of events. actual tag will be this_tag_prefix.tables_tag (optional)'
|
34
51
|
config_param :tag_prefix, :string, :default => nil
|
52
|
+
desc 'interval to run SQLs (optional)'
|
35
53
|
config_param :select_interval, :time, :default => 60
|
54
|
+
desc 'limit of number of rows for each SQL(optional)'
|
36
55
|
config_param :select_limit, :time, :default => 500
|
37
56
|
|
38
57
|
unless method_defined?(:log)
|
@@ -86,8 +105,7 @@ module Fluent
|
|
86
105
|
|
87
106
|
# if update_column is not set, here uses primary key
|
88
107
|
unless @update_column
|
89
|
-
|
90
|
-
pk = columns[@model.primary_key]
|
108
|
+
pk = @model.columns_hash[@model.primary_key]
|
91
109
|
unless pk
|
92
110
|
raise "Composite primary key is not supported. Set update_column parameter to <table> section."
|
93
111
|
end
|
@@ -105,7 +123,6 @@ module Fluent
|
|
105
123
|
relation = relation.limit(limit) if limit > 0
|
106
124
|
|
107
125
|
now = Engine.now
|
108
|
-
entry_name = @model.table_name.singularize
|
109
126
|
|
110
127
|
me = MultiEventStream.new
|
111
128
|
relation.each do |obj|
|
@@ -226,6 +243,14 @@ module Fluent
|
|
226
243
|
until @stop_flag
|
227
244
|
sleep @select_interval
|
228
245
|
|
246
|
+
begin
|
247
|
+
conn = @base_model.connection
|
248
|
+
conn.active? || conn.reconnect!
|
249
|
+
rescue => e
|
250
|
+
log.warn "can't connect to database. Reconnect at next try"
|
251
|
+
next
|
252
|
+
end
|
253
|
+
|
229
254
|
@tables.each do |t|
|
230
255
|
begin
|
231
256
|
last_record = @state_store.last_records[t.table]
|
@@ -5,13 +5,29 @@ module Fluent
|
|
5
5
|
include SetTimeKeyMixin
|
6
6
|
include SetTagKeyMixin
|
7
7
|
|
8
|
+
# For fluentd v0.12.16 or earlier
|
9
|
+
class << self
|
10
|
+
unless method_defined?(:desc)
|
11
|
+
def desc(description)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'RDBMS host'
|
8
17
|
config_param :host, :string
|
18
|
+
desc 'RDBMS port'
|
9
19
|
config_param :port, :integer, :default => nil
|
20
|
+
desc 'RDBMS driver name.'
|
10
21
|
config_param :adapter, :string
|
22
|
+
desc 'RDBMS login user name'
|
11
23
|
config_param :username, :string, :default => nil
|
24
|
+
desc 'RDBMS login password'
|
12
25
|
config_param :password, :string, :default => nil, :secret => true
|
26
|
+
desc 'RDBMS database name'
|
13
27
|
config_param :database, :string
|
28
|
+
desc 'RDBMS socket path'
|
14
29
|
config_param :socket, :string, :default => nil
|
30
|
+
desc 'remove the given prefix from the events'
|
15
31
|
config_param :remove_tag_prefix, :string, :default => nil
|
16
32
|
|
17
33
|
attr_accessor :tables
|
@@ -64,7 +80,7 @@ module Fluent
|
|
64
80
|
@model.define_singleton_method(:model_name) { model_name }
|
65
81
|
|
66
82
|
# TODO: check column_names and table schema
|
67
|
-
|
83
|
+
# @model.column_names
|
68
84
|
end
|
69
85
|
|
70
86
|
def import(chunk)
|
@@ -199,6 +215,9 @@ module Fluent
|
|
199
215
|
end
|
200
216
|
|
201
217
|
def write(chunk)
|
218
|
+
conn = @base_model.connection
|
219
|
+
conn.active? || conn.reconnect!
|
220
|
+
|
202
221
|
@tables.each { |table|
|
203
222
|
if table.pattern.match(chunk.key)
|
204
223
|
return table.import(chunk)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-sql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.12.17
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '2'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: 0.12.17
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '2'
|
@@ -78,6 +78,7 @@ executables: []
|
|
78
78
|
extensions: []
|
79
79
|
extra_rdoc_files: []
|
80
80
|
files:
|
81
|
+
- ".travis.yml"
|
81
82
|
- Gemfile
|
82
83
|
- README.md
|
83
84
|
- Rakefile
|