fluent-plugin-mssql2 0.0.8
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 +7 -0
- data/lib/fluent/plugin/out_mssql2.rb +52 -0
- metadata +72 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: eed604f11047b46437a30a93bf9c96c16513322b
|
|
4
|
+
data.tar.gz: 5b20e8b8c82d703cbe34403839cfa60cbc987f2c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 273d3595d5188a2d98f34f9ac538899924cc5c919df3d5ac8f2054ec9b27be166c4a71e7a433a94eccfdf0acde6fd522f7afd2ea389e09b51f89df990a7f0d7b
|
|
7
|
+
data.tar.gz: 591cea4a9410e50128cd615130eb7f8512389b43ad04d828b30f983b22b115f3cd989ab96f47b0ea4179a301879a943c0e567981e5e007508a33748cc43b3dca
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require 'sequel'
|
|
2
|
+
require 'json'
|
|
3
|
+
# require 'pp'
|
|
4
|
+
# require 'logger'
|
|
5
|
+
|
|
6
|
+
class Mssql2Output < Fluent::BufferedOutput
|
|
7
|
+
Fluent::Plugin.register_output('mssql2', self)
|
|
8
|
+
|
|
9
|
+
include Fluent::SetTimeKeyMixin
|
|
10
|
+
include Fluent::SetTagKeyMixin
|
|
11
|
+
|
|
12
|
+
config_param :username, :string
|
|
13
|
+
config_param :password, :string
|
|
14
|
+
config_param :host, :string
|
|
15
|
+
config_param :database, :string
|
|
16
|
+
config_param :table, :string
|
|
17
|
+
|
|
18
|
+
def configure(conf)
|
|
19
|
+
super
|
|
20
|
+
@format_proc = Proc.new{|tag, time, record| record.to_json}
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def format(tag, time, record)
|
|
24
|
+
[tag, time, @format_proc.call(tag, time, record)].to_msgpack
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def client
|
|
28
|
+
begin
|
|
29
|
+
db = Sequel.tinytds(username: @username, password: @password, host: @host, database: @database)
|
|
30
|
+
# db.loggers << Logger.new($stdout)
|
|
31
|
+
rescue
|
|
32
|
+
raise Fluent::ConfigError, "Cannot open database, check user or password"
|
|
33
|
+
end
|
|
34
|
+
db
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def write(chunk)
|
|
38
|
+
a = []
|
|
39
|
+
c = client
|
|
40
|
+
|
|
41
|
+
chunk.msgpack_each{|tag, time, data|
|
|
42
|
+
a << JSON.parse(data)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
# pp a
|
|
46
|
+
begin
|
|
47
|
+
c[@table.gsub('.', '__').to_sym].multi_insert(a)
|
|
48
|
+
ensure
|
|
49
|
+
c.disconnect
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: fluent-plugin-mssql2
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.8
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- u89012
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-07-10 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: sequel
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '4.8'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '4.8'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: tiny_tds
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0.6'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0.6'
|
|
41
|
+
description: A no frills fluentd buffered plugin to write to microsoft sql server
|
|
42
|
+
email: u89012@gmail.com
|
|
43
|
+
executables: []
|
|
44
|
+
extensions: []
|
|
45
|
+
extra_rdoc_files: []
|
|
46
|
+
files:
|
|
47
|
+
- lib/fluent/plugin/out_mssql2.rb
|
|
48
|
+
homepage: http://github.com/u89012/fluent-plugin-mssql2
|
|
49
|
+
licenses:
|
|
50
|
+
- MIT
|
|
51
|
+
metadata: {}
|
|
52
|
+
post_install_message:
|
|
53
|
+
rdoc_options: []
|
|
54
|
+
require_paths:
|
|
55
|
+
- lib
|
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0'
|
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
|
+
requirements:
|
|
63
|
+
- - ">="
|
|
64
|
+
- !ruby/object:Gem::Version
|
|
65
|
+
version: '0'
|
|
66
|
+
requirements: []
|
|
67
|
+
rubyforge_project:
|
|
68
|
+
rubygems_version: 2.2.2
|
|
69
|
+
signing_key:
|
|
70
|
+
specification_version: 4
|
|
71
|
+
summary: A no frills fluentd buffered plugin to write to microsoft sql server
|
|
72
|
+
test_files: []
|