fluent-plugin-postgres 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7dc444608cda7a7c9564dfef3351887db330fd89fd07544dc70e63c05a50804f
4
- data.tar.gz: b8ab67866697933b5f04e5715b82d9a0a5cc9773e04a5d1b8c5c8994e74ed4da
3
+ metadata.gz: 722f5f89deefecc29b2b0af9f988deeede2a3844cdbb45b45912735de81baee6
4
+ data.tar.gz: 87fc645e91e9ceeaf92046819acc4c265b36240678c7ea30f55d402448648444
5
5
  SHA512:
6
- metadata.gz: 49d8fc658ee51563dec9310093ffa0bee409b7a5a8f401103bf6b78c39a5198956f80b47b45d02f2dfbdcb0d6d5bbab3231ad68ed893ca67310262887919df63
7
- data.tar.gz: 465de8a0e4a8f31d808cb19c359a7bbd59a45111a35c90559be620130accba79b76052a887ef6fa22aa8dd3ed0c4532050f363da935c37bbfc5c1ae2ed075434
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.2'
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 2.0'
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
- class Fluent::PostgresOutput < Fluent::BufferedOutput
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
- include Fluent::SetTimeKeyMixin
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,
@@ -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, tag='test')
19
- d = Fluent::Test::BufferedOutputTestDriver.new(Fluent::PostgresOutput, tag).configure(conf)
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 = Time.utc(2012,12,17,1,23,45).to_i
88
+ time = event_time('2012-12-17 01:23:45 UTC')
89
89
  record = {'field1'=>'value1','field2'=>'value2','field3'=>'value3','field4'=>'value4'}
90
- d.emit(record, time)
91
- d.expect_format ['test', time, ['2012-12-17T01:23:45Z','test','value1','value2','value3','value4']].to_msgpack
92
- d.run
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 = Time.new(2012,12,17,9,23,45,'+09:00').to_i
114
+ time = event_time('2012-12-17 09:23:45 +0900')
114
115
  record = {'field1'=>'value1','field2'=>'value2','field3'=>'value3','field4'=>'value4'}
115
- d.emit(record, time)
116
- d.expect_format ['test', time, ['20121217-002345','test','value1','value2','value3','value4']].to_msgpack
117
- d.run
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.2
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-19 00:00:00.000000000 Z
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: '0'
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: '0'
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 2.0
95
+ - Apache-2.0
90
96
  metadata: {}
91
97
  post_install_message:
92
98
  rdoc_options: []