fluent-plugin-postgres 0.0.2 → 0.1.0
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/fluent-plugin-postgres.gemspec +3 -3
- data/lib/fluent/plugin/out_postgres.rb +15 -8
- data/test/helper.rb +3 -0
- data/test/plugin/test_out_postgres.rb +12 -11
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 722f5f89deefecc29b2b0af9f988deeede2a3844cdbb45b45912735de81baee6
|
4
|
+
data.tar.gz: 87fc645e91e9ceeaf92046819acc4c265b36240678c7ea30f55d402448648444
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfc1105541ab9e8aa9605d1be5fb33d0b37f071b4bced59c411fa4a067232c29f836bb1d38a77be232765b9302f7ac89bcb96a5df218b7ef63e931ba70d782dd
|
7
|
+
data.tar.gz: 40212f615e954ba04ee807c4bc866b74e144cdc9886ad86cd34554d78c4c4e655895c16a881b84d22b5e33889802c98acebdf0f9749b40a17d2846e4cc9246ab
|
@@ -1,20 +1,20 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = 'fluent-plugin-postgres'
|
4
|
-
s.version = '0.0
|
4
|
+
s.version = '0.1.0'
|
5
5
|
s.authors = ['TAGOMORI Satoshi', 'Diogo Terror', 'pitr']
|
6
6
|
s.email = ['team@uken.com']
|
7
7
|
s.description = %q{fluent plugin to insert on PostgreSQL}
|
8
8
|
s.summary = %q{fluent plugin to insert on PostgreSQL}
|
9
9
|
s.homepage = 'https://github.com/uken/fluent-plugin-postgres'
|
10
|
-
s.license = 'Apache
|
10
|
+
s.license = 'Apache-2.0'
|
11
11
|
|
12
12
|
s.files = `git ls-files`.split($\)
|
13
13
|
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
14
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
15
15
|
s.require_paths = ['lib']
|
16
16
|
|
17
|
-
s.add_dependency 'fluentd'
|
17
|
+
s.add_dependency 'fluentd', ['>= 0.14.15', '< 2']
|
18
18
|
s.add_dependency 'pg'
|
19
19
|
|
20
20
|
s.add_development_dependency 'rake'
|
@@ -1,8 +1,10 @@
|
|
1
|
-
|
1
|
+
require 'fluent/plugin/output'
|
2
|
+
require 'pg'
|
3
|
+
|
4
|
+
class Fluent::Plugin::PostgresOutput < Fluent::Plugin::Output
|
2
5
|
Fluent::Plugin.register_output('postgres', self)
|
3
6
|
|
4
|
-
|
5
|
-
include Fluent::SetTagKeyMixin
|
7
|
+
helpers :inject, :compat_parameters
|
6
8
|
|
7
9
|
config_param :host, :string
|
8
10
|
config_param :port, :integer, :default => nil
|
@@ -19,13 +21,9 @@ class Fluent::PostgresOutput < Fluent::BufferedOutput
|
|
19
21
|
|
20
22
|
attr_accessor :handler
|
21
23
|
|
22
|
-
def initialize
|
23
|
-
super
|
24
|
-
require 'pg'
|
25
|
-
end
|
26
|
-
|
27
24
|
# We don't currently support mysql's analogous json format
|
28
25
|
def configure(conf)
|
26
|
+
compat_parameters_convert(conf, :inject)
|
29
27
|
super
|
30
28
|
|
31
29
|
if @format == 'json'
|
@@ -52,9 +50,18 @@ class Fluent::PostgresOutput < Fluent::BufferedOutput
|
|
52
50
|
end
|
53
51
|
|
54
52
|
def format(tag, time, record)
|
53
|
+
record = inject_values_to_record(tag, time, record)
|
55
54
|
[tag, time, @format_proc.call(tag, time, record)].to_msgpack
|
56
55
|
end
|
57
56
|
|
57
|
+
def multi_workers_ready?
|
58
|
+
true
|
59
|
+
end
|
60
|
+
|
61
|
+
def formatted_to_msgpack_binary?
|
62
|
+
true
|
63
|
+
end
|
64
|
+
|
58
65
|
def client
|
59
66
|
PG::Connection.new({
|
60
67
|
:host => @host, :port => @port,
|
data/test/helper.rb
CHANGED
@@ -12,6 +12,8 @@ require 'test/unit'
|
|
12
12
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
13
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
14
|
require 'fluent/test'
|
15
|
+
require 'fluent/test/driver/output'
|
16
|
+
require 'fluent/test/helpers'
|
15
17
|
unless ENV.has_key?('VERBOSE')
|
16
18
|
nulllogger = Object.new
|
17
19
|
nulllogger.instance_eval {|obj|
|
@@ -25,4 +27,5 @@ end
|
|
25
27
|
require 'fluent/plugin/out_postgres'
|
26
28
|
|
27
29
|
class Test::Unit::TestCase
|
30
|
+
include Fluent::Test::Helpers
|
28
31
|
end
|
@@ -15,8 +15,8 @@ key_names field1,field2,field3
|
|
15
15
|
sql INSERT INTO baz (col1,col2,col3,col4) VALUES (?,?,?,?)
|
16
16
|
]
|
17
17
|
|
18
|
-
def create_driver(conf=CONFIG
|
19
|
-
d = Fluent::Test::
|
18
|
+
def create_driver(conf=CONFIG)
|
19
|
+
d = Fluent::Test::Driver::Output.new(Fluent::Plugin::PostgresOutput).configure(conf)
|
20
20
|
d.instance.instance_eval {
|
21
21
|
def client
|
22
22
|
obj = Object.new
|
@@ -85,11 +85,12 @@ sql INSERT INTO baz (coltime,coltag,col1,col2,col3,col4) VALUES (?,?,?,?,?,?)
|
|
85
85
|
]
|
86
86
|
assert_equal 'INSERT INTO baz (coltime,coltag,col1,col2,col3,col4) VALUES (?,?,?,?,?,?)', d.instance.sql
|
87
87
|
|
88
|
-
time =
|
88
|
+
time = event_time('2012-12-17 01:23:45 UTC')
|
89
89
|
record = {'field1'=>'value1','field2'=>'value2','field3'=>'value3','field4'=>'value4'}
|
90
|
-
d.
|
91
|
-
|
92
|
-
|
90
|
+
d.run(default_tag: 'test') do
|
91
|
+
d.feed(time, record)
|
92
|
+
end
|
93
|
+
assert_equal ['test', time, ['2012-12-17T01:23:45Z','test','value1','value2','value3','value4']].to_msgpack, d.formatted[0]
|
93
94
|
end
|
94
95
|
|
95
96
|
def test_time_and_tag_key_complex
|
@@ -110,11 +111,11 @@ sql INSERT INTO baz (coltime,coltag,col1,col2,col3,col4) VALUES (?,?,?,?,?,?)
|
|
110
111
|
]
|
111
112
|
assert_equal 'INSERT INTO baz (coltime,coltag,col1,col2,col3,col4) VALUES (?,?,?,?,?,?)', d.instance.sql
|
112
113
|
|
113
|
-
time =
|
114
|
+
time = event_time('2012-12-17 09:23:45 +0900')
|
114
115
|
record = {'field1'=>'value1','field2'=>'value2','field3'=>'value3','field4'=>'value4'}
|
115
|
-
d.
|
116
|
-
|
117
|
-
|
116
|
+
d.run(default_tag: 'test') do
|
117
|
+
d.feed(time, record)
|
118
|
+
end
|
119
|
+
assert_equal ['test', time, ['20121217-002345','test','value1','value2','value3','value4']].to_msgpack, d.formatted[0]
|
118
120
|
end
|
119
121
|
end
|
120
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-postgres
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TAGOMORI Satoshi
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-09-
|
13
|
+
date: 2018-09-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: fluentd
|
@@ -18,14 +18,20 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 0.14.15
|
22
|
+
- - "<"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '2'
|
22
25
|
type: :runtime
|
23
26
|
prerelease: false
|
24
27
|
version_requirements: !ruby/object:Gem::Requirement
|
25
28
|
requirements:
|
26
29
|
- - ">="
|
27
30
|
- !ruby/object:Gem::Version
|
28
|
-
version:
|
31
|
+
version: 0.14.15
|
32
|
+
- - "<"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '2'
|
29
35
|
- !ruby/object:Gem::Dependency
|
30
36
|
name: pg
|
31
37
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,7 +92,7 @@ files:
|
|
86
92
|
- test/plugin/test_out_postgres.rb
|
87
93
|
homepage: https://github.com/uken/fluent-plugin-postgres
|
88
94
|
licenses:
|
89
|
-
- Apache
|
95
|
+
- Apache-2.0
|
90
96
|
metadata: {}
|
91
97
|
post_install_message:
|
92
98
|
rdoc_options: []
|