fluent-plugin-pghstore 0.2.7 → 0.2.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 +4 -4
- data/fluent-plugin-pghstore.gemspec +2 -3
- data/lib/fluent/plugin/out_pghstore.rb +31 -9
- data/test/helper.rb +2 -0
- data/test/plugin/test_out_pghstore.rb +17 -13
- metadata +24 -27
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8590eee6c44171264101a57265427a6c03312f9d
|
|
4
|
+
data.tar.gz: 1161a01eac5df5e0bf68526064a93c553cb5cf60
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aa217601749dc071700f5c8698853c2f2bf17f9a7e45640c36c3184c757416711c23cbd7a911dd563a9f7c38f0eb0d664f1a254c79632194eede10dc09cd4953
|
|
7
|
+
data.tar.gz: 1ca9503e33c79b7aadc3565a82dcb3ae71c9d39aa705f449a8fca39c7671c9925087e522a67ef8d58569d7cbd533beee2c78eb6276b14571fdc13246297aebcd
|
|
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = "fluent-plugin-pghstore"
|
|
6
|
-
s.version = "0.2.
|
|
6
|
+
s.version = "0.2.8"
|
|
7
7
|
s.authors = ["WAKAYAMA Shirou"]
|
|
8
8
|
s.email = ["shirou.faw@gmail.com"]
|
|
9
9
|
s.homepage = "https://github.com/shirou/fluent-plugin-pghstore"
|
|
@@ -21,10 +21,9 @@ Gem::Specification.new do |s|
|
|
|
21
21
|
# specify any dependencies here; for example:
|
|
22
22
|
s.add_development_dependency "rspec", "~> 3.2.0"
|
|
23
23
|
# s.add_runtime_dependency "rest-client"
|
|
24
|
-
s.add_development_dependency "fluentd", [">= 0.12.5", "< 2"]
|
|
25
24
|
s.add_development_dependency "pg", "~> 0.18.1"
|
|
26
25
|
s.add_development_dependency "rake", ">= 11.0"
|
|
27
26
|
s.add_development_dependency "test-unit", "~> 3.1.0"
|
|
28
|
-
|
|
27
|
+
s.add_runtime_dependency "fluentd", [">= 0.14.0", "< 2"]
|
|
29
28
|
# s.add_runtime_dependency "pg", "~> 0.18.1"
|
|
30
29
|
end
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
require 'pg'
|
|
2
|
+
require 'fluent/plugin/output'
|
|
3
|
+
|
|
4
|
+
class Fluent::Plugin::PgHStoreOutput < Fluent::Plugin::Output
|
|
2
5
|
Fluent::Plugin.register_output('pghstore', self)
|
|
3
6
|
|
|
7
|
+
helpers :compat_parameters
|
|
8
|
+
|
|
9
|
+
DEFAULT_BUFFER_TYPE = "memory"
|
|
10
|
+
|
|
4
11
|
config_param :database, :string
|
|
5
12
|
config_param :table, :string, :default => 'fluentd_store'
|
|
6
13
|
config_param :host, :string, :default => 'localhost'
|
|
@@ -10,12 +17,22 @@ class Fluent::PgHStoreOutput < Fluent::BufferedOutput
|
|
|
10
17
|
|
|
11
18
|
config_param :table_option, :string, :default => nil
|
|
12
19
|
|
|
20
|
+
config_section :buffer do
|
|
21
|
+
config_set_default :@type, DEFAULT_BUFFER_TYPE
|
|
22
|
+
config_set_default :chunk_keys, ['tag']
|
|
23
|
+
end
|
|
24
|
+
|
|
13
25
|
def initialize
|
|
14
26
|
super
|
|
15
|
-
require 'pg'
|
|
16
27
|
@conn = nil
|
|
17
28
|
end
|
|
18
29
|
|
|
30
|
+
def configure(conf)
|
|
31
|
+
compat_parameters_convert(conf, :buffer)
|
|
32
|
+
super
|
|
33
|
+
raise Fluent::ConfigError, "'tag' in chunk_keys is required." if not @chunk_key_tag
|
|
34
|
+
end
|
|
35
|
+
|
|
19
36
|
def start
|
|
20
37
|
super
|
|
21
38
|
|
|
@@ -31,19 +48,24 @@ class Fluent::PgHStoreOutput < Fluent::BufferedOutput
|
|
|
31
48
|
end
|
|
32
49
|
|
|
33
50
|
def format(tag, time, record)
|
|
34
|
-
[
|
|
51
|
+
[time, record].to_msgpack
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def formatted_to_msgpack_binary
|
|
55
|
+
true
|
|
35
56
|
end
|
|
36
57
|
|
|
37
58
|
def write(chunk)
|
|
38
59
|
conn = get_connection()
|
|
39
60
|
return if conn == nil # TODO: chunk will be dropped. should retry?
|
|
40
61
|
|
|
41
|
-
chunk.
|
|
62
|
+
tag = chunk.metadata.tag
|
|
63
|
+
chunk.msgpack_each {|(time_str, record)|
|
|
42
64
|
sql = generate_sql(conn, tag, time_str, record)
|
|
43
65
|
begin
|
|
44
66
|
conn.exec(sql)
|
|
45
67
|
rescue PGError => e
|
|
46
|
-
|
|
68
|
+
log.error "PGError: " + e.message # dropped if error
|
|
47
69
|
end
|
|
48
70
|
}
|
|
49
71
|
|
|
@@ -94,7 +116,7 @@ SQL
|
|
|
94
116
|
@conn = PG.connect(:dbname => @database, :host => @host, :port => @port)
|
|
95
117
|
end
|
|
96
118
|
rescue PGError => e
|
|
97
|
-
|
|
119
|
+
log.error "Error: could not connect database:" + @database
|
|
98
120
|
return nil
|
|
99
121
|
end
|
|
100
122
|
|
|
@@ -128,12 +150,12 @@ SQL
|
|
|
128
150
|
begin
|
|
129
151
|
conn.exec(sql)
|
|
130
152
|
rescue PGError => e
|
|
131
|
-
|
|
132
|
-
|
|
153
|
+
log.error "Error at create_table:" + e.message
|
|
154
|
+
log.error "SQL:" + sql
|
|
133
155
|
end
|
|
134
156
|
conn.close
|
|
135
157
|
|
|
136
|
-
|
|
158
|
+
log.warn "table #{tablename} was not exist. created it."
|
|
137
159
|
end
|
|
138
160
|
|
|
139
161
|
end
|
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|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
require 'helper'
|
|
2
2
|
|
|
3
3
|
class PGHStoreOutputTest < Test::Unit::TestCase
|
|
4
|
+
include Fluent::Test::Helpers
|
|
5
|
+
|
|
4
6
|
def setup
|
|
5
7
|
Fluent::Test.setup
|
|
6
8
|
end
|
|
@@ -18,8 +20,8 @@ class PGHStoreOutputTest < Test::Unit::TestCase
|
|
|
18
20
|
password #{PASSWORD}
|
|
19
21
|
]
|
|
20
22
|
|
|
21
|
-
def create_driver(conf = CONFIG
|
|
22
|
-
Fluent::Test::
|
|
23
|
+
def create_driver(conf = CONFIG)
|
|
24
|
+
Fluent::Test::Driver::Output.new(Fluent::Plugin::PgHStoreOutput).configure(conf)
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
def test_configure
|
|
@@ -36,24 +38,26 @@ class PGHStoreOutputTest < Test::Unit::TestCase
|
|
|
36
38
|
d = create_driver
|
|
37
39
|
with_connection(d) do |_conn|
|
|
38
40
|
|
|
39
|
-
time =
|
|
40
|
-
d.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
time = event_time("2011-01-02 13:14:15 UTC")
|
|
42
|
+
d.run(default_tag: "test.input") do
|
|
43
|
+
d.feed(time, {"a"=>1})
|
|
44
|
+
d.feed(time, {"a"=>2})
|
|
45
|
+
end
|
|
46
|
+
formatted = d.formatted
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
assert_equal [time, {"a"=>1}].to_msgpack, formatted[0]
|
|
49
|
+
assert_equal [time, {"a"=>2}].to_msgpack, formatted[1]
|
|
47
50
|
end
|
|
48
51
|
end
|
|
49
52
|
|
|
50
53
|
def test_write
|
|
51
54
|
d = create_driver
|
|
52
55
|
with_connection(d) do |conn|
|
|
53
|
-
time =
|
|
54
|
-
d.
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
time = event_time("2011-01-02 13:14:15 UTC")
|
|
57
|
+
d.run(default_tag: "test.input") do
|
|
58
|
+
d.feed(time, {"a"=>1})
|
|
59
|
+
d.feed(time, {"a"=>2})
|
|
60
|
+
end
|
|
57
61
|
|
|
58
62
|
wait_data(conn)
|
|
59
63
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluent-plugin-pghstore
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- WAKAYAMA Shirou
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2018-04-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|
|
@@ -24,26 +24,6 @@ dependencies:
|
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: 3.2.0
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: fluentd
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - ">="
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: 0.12.5
|
|
34
|
-
- - "<"
|
|
35
|
-
- !ruby/object:Gem::Version
|
|
36
|
-
version: '2'
|
|
37
|
-
type: :development
|
|
38
|
-
prerelease: false
|
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
40
|
-
requirements:
|
|
41
|
-
- - ">="
|
|
42
|
-
- !ruby/object:Gem::Version
|
|
43
|
-
version: 0.12.5
|
|
44
|
-
- - "<"
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: '2'
|
|
47
27
|
- !ruby/object:Gem::Dependency
|
|
48
28
|
name: pg
|
|
49
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -86,6 +66,26 @@ dependencies:
|
|
|
86
66
|
- - "~>"
|
|
87
67
|
- !ruby/object:Gem::Version
|
|
88
68
|
version: 3.1.0
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: fluentd
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 0.14.0
|
|
76
|
+
- - "<"
|
|
77
|
+
- !ruby/object:Gem::Version
|
|
78
|
+
version: '2'
|
|
79
|
+
type: :runtime
|
|
80
|
+
prerelease: false
|
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
82
|
+
requirements:
|
|
83
|
+
- - ">="
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: 0.14.0
|
|
86
|
+
- - "<"
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '2'
|
|
89
89
|
description: Output to PostgreSQL database which has a hstore extension
|
|
90
90
|
email:
|
|
91
91
|
- shirou.faw@gmail.com
|
|
@@ -124,11 +124,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
124
124
|
version: '0'
|
|
125
125
|
requirements: []
|
|
126
126
|
rubyforge_project: fluent-plugin-pghstore
|
|
127
|
-
rubygems_version: 2.
|
|
127
|
+
rubygems_version: 2.6.13
|
|
128
128
|
signing_key:
|
|
129
129
|
specification_version: 4
|
|
130
130
|
summary: Output to PostgreSQL database which has a hstore extension
|
|
131
|
-
test_files:
|
|
132
|
-
- test/helper.rb
|
|
133
|
-
- test/plugin/test_out_pghstore.rb
|
|
134
|
-
- test/plugin/test_out_pghstore.rb.bak
|
|
131
|
+
test_files: []
|