fluent-plugin-mssql22 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fluent/plugin/out_mssql22.rb +35 -29
- metadata +1 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96b507a34fcc8dfb8d437cf909bafdb64f201d4e
|
4
|
+
data.tar.gz: 962bb9eddf8f8ef000186816797b745c2e6f69de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2a6a3f9dfdcb6cd15890148a62a6c54a0bf8e7183be2855049dc3389a865f3bcc1b13bc851d92f5eb82a33c35fa2f75733e73f988836108595c8184f88e933f
|
7
|
+
data.tar.gz: 554abc9c573fef2e1d591a51ec4b8bc40fe4439fa7f18b3f28f12458b25c5ca02fa3b96a5b4f19b4a0ef21de8b748a419b994285d1b560b20b6914542d1c303b
|
@@ -11,14 +11,23 @@ class Mssql22Output < Fluent::BufferedOutput
|
|
11
11
|
config_param :username, :string
|
12
12
|
config_param :password, :string
|
13
13
|
config_param :host, :string
|
14
|
-
config_param :port, :
|
14
|
+
config_param :port, :integer
|
15
15
|
config_param :database, :string
|
16
|
-
config_param :
|
16
|
+
config_param :query, :string
|
17
|
+
config_param :poolsize, :integer, default: 10
|
18
|
+
config_param :timeout, :integer, default: 60
|
19
|
+
config_param :login_timeout, :integer, default: 10
|
20
|
+
config_param :session_options, :string, default: nil
|
17
21
|
|
18
22
|
def configure(conf)
|
19
23
|
super
|
20
|
-
@keys = @
|
24
|
+
@keys = @query.scan(/\?\{(.*?)\}/).flatten
|
21
25
|
@format_proc = Proc.new{|tag, time, record| @keys.map{|k| [k,record[k]]}.to_h}
|
26
|
+
|
27
|
+
unless @session_options.nil?
|
28
|
+
@session_sets = @session_options.split(';')
|
29
|
+
end
|
30
|
+
|
22
31
|
end
|
23
32
|
|
24
33
|
def format(tag, time, record)
|
@@ -27,20 +36,29 @@ class Mssql22Output < Fluent::BufferedOutput
|
|
27
36
|
|
28
37
|
def client
|
29
38
|
begin
|
30
|
-
pool = ConnectionPool.new(size:
|
31
|
-
TinyTds::Client.new(
|
39
|
+
pool = ConnectionPool.new(size: @poolsize) {
|
40
|
+
client = TinyTds::Client.new(
|
32
41
|
username: @username,
|
33
42
|
password: @password,
|
34
43
|
host: @host,
|
35
44
|
port: @port,
|
36
45
|
database: @database,
|
37
|
-
appname: 'fluentd
|
38
|
-
|
46
|
+
appname: 'fluentd-tinytds',
|
47
|
+
timeout: @timeout,
|
48
|
+
login_timeout: @login_timeout
|
39
49
|
)
|
50
|
+
|
51
|
+
unless @session_sets.nil?
|
52
|
+
@session_sets.each do |set|
|
53
|
+
client.execute(set).do
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
client
|
40
58
|
}
|
41
59
|
|
42
|
-
rescue
|
43
|
-
raise Fluent::ConfigError,
|
60
|
+
rescue Exception => e
|
61
|
+
raise Fluent::ConfigError, e.message
|
44
62
|
end
|
45
63
|
|
46
64
|
pool
|
@@ -55,37 +73,25 @@ class Mssql22Output < Fluent::BufferedOutput
|
|
55
73
|
super
|
56
74
|
end
|
57
75
|
|
58
|
-
def
|
59
|
-
|
76
|
+
def query_bind(data)
|
77
|
+
query = @query
|
60
78
|
data.map do |k,v|
|
61
|
-
|
79
|
+
query = query.gsub("?{#{k}}",v.to_s.gsub(/'/,"''"))
|
62
80
|
|
63
81
|
end
|
64
|
-
|
82
|
+
query
|
65
83
|
end
|
66
84
|
|
67
85
|
def write(chunk)
|
68
86
|
begin
|
69
|
-
|
70
|
-
|
87
|
+
@cp.with { |c| c.execute('select 1;').do }
|
88
|
+
rescue
|
71
89
|
@cp = client
|
72
|
-
ensure
|
73
|
-
@cp.with do |c|
|
74
|
-
c.execute('SET ANSI_NULLS ON;').do
|
75
|
-
c.execute('SET ANSI_PADDING ON;').do
|
76
|
-
c.execute('SET ANSI_WARNINGS ON;').do
|
77
|
-
c.execute('SET ARITHABORT ON;').do
|
78
|
-
c.execute('SET CONCAT_NULL_YIELDS_NULL ON;').do
|
79
|
-
c.execute('SET NUMERIC_ROUNDABORT ON;').do
|
80
|
-
c.execute('SET QUOTED_IDENTIFIER ON;').do
|
81
|
-
c.execute('SET NUMERIC_ROUNDABORT OFF;').do
|
82
|
-
end
|
83
90
|
end
|
84
91
|
|
85
92
|
chunk.msgpack_each do |tag, time, data|
|
86
|
-
|
87
|
-
@cp.with {|c| c.execute( sql_bind(data) ).do}
|
93
|
+
@cp.with {|c| c.execute( query_bind(data) ).do}
|
88
94
|
end
|
89
95
|
end
|
90
96
|
|
91
|
-
end
|
97
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-mssql22
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zle0
|
@@ -10,20 +10,6 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2021-06-24 00:00:00.000000000 Z
|
12
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.14.10
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.14.10
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: connection_pool
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|