fluent-plugin-pgjson 1.0.1 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb3799124226f80cb140cca512a0a09ec442b2cc4004a589f456bc0a1129bb68
4
- data.tar.gz: 93d61f535fba84b6f476f8a0b6b471fd5d2c53076ec65aa9464c97164e37f4aa
3
+ metadata.gz: 5b50876105f70aba6215cda3bea847f0497209437587954d46808e4820ee62ad
4
+ data.tar.gz: c201ea0e5587f595dfb537840efd474689342f2a53683d1c5cce8d09860f8684
5
5
  SHA512:
6
- metadata.gz: defaa3ee2680a7927e36f4bb0b52013ee296ae31da2cc554a6688802c3d809bc6495914bc0f7f2c01040f972f962fa68d42b81610d873638be55f695be0f0364
7
- data.tar.gz: f733dd18d69b42b4d2bdd5aba65c071b0200e6ec5b64cb7022e30ce45b083630a19454a52b54d8838cd81a9569375037ac501a1a2b938701dd7d29f79849df30
6
+ metadata.gz: f9d9799ad2d645a1a72f569f18aa8312d5d920e0b85707e23b1cac36cabe98ec4abfb1ff0335af13fd26db6bd93b09ea9ce47d140684c4f286392d86159fa392
7
+ data.tar.gz: 948bdf734a3506afafaba993d77ff6e62c18afe141f412a608c2b74debe75a58ed81c5e0883ae1484ae2505817cebbaa2cdb96f1a99bc6035b59b42cbda6f8f2
@@ -0,0 +1,47 @@
1
+ name: linux
2
+ on:
3
+ - push
4
+ - pull_request
5
+ jobs:
6
+ build:
7
+ runs-on: ${{ matrix.os }}
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ ruby: [ '2.4', '2.5', '2.6', '2.7', '3.0' ]
12
+ postgres: [ '9', '10', '11', '12', '13' ]
13
+ os:
14
+ - ubuntu-latest
15
+ services:
16
+ postgres:
17
+ image: postgres:${{ matrix.postgres }}
18
+ ports:
19
+ - 5432:5432
20
+ env:
21
+ POSTGRES_USER: postgres
22
+ POSTGRES_PASSWORD: password
23
+ POSTGRES_DB: test
24
+ options: >-
25
+ --health-cmd pg_isready
26
+ --health-interval 10s
27
+ --health-timeout 5s
28
+ --health-retries 5
29
+ name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }}
30
+ steps:
31
+ - uses: actions/checkout@v2
32
+ - uses: ruby/setup-ruby@v1
33
+ with:
34
+ ruby-version: ${{ matrix.ruby }}
35
+ - name: prepare database
36
+ env:
37
+ PGPASSWORD: password
38
+ run: |
39
+ psql -h localhost -p 5432 -U postgres -c "create role fluentd with LOGIN CREATEDB password 'fluentd';"
40
+ psql -h localhost -p 5432 -U postgres -c "create database pgjsontest owner fluentd encoding 'utf-8'" -U postgres
41
+ - name: unit testing
42
+ env:
43
+ CI: true
44
+ run: |
45
+ gem install bundler rake
46
+ bundle install --jobs 4 --retry 3
47
+ bundle exec rake test
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Fluent::Plugin::PgJson, a plugin for [Fluentd](http://fluentd.org)
2
2
 
3
+ ![linux](https://github.com/fluent-plugins-nursery/fluent-plugin-pgjson/workflows/linux/badge.svg?branch=master)
4
+
3
5
  Output Plugin for PostgreSQL Json Type.
4
6
 
5
7
  <b>Json type is availble in PostgreSQL version over 9.2</b>
@@ -55,42 +57,37 @@ CREATE TABLE fluentd (
55
57
  ```
56
58
  <match **>
57
59
  @type pgjson
58
- host localhost
59
- port 5432
60
- sslmode require
60
+ #host localhost
61
+ #port 5432
62
+ #sslmode prefer
61
63
  database fluentd
62
64
  table fluentd
63
65
  user postgres
64
66
  password postgres
65
- time_col time
66
- tag_col tag
67
- record_col record
67
+ #time_col time
68
+ #tag_col tag
69
+ #record_col record
70
+ #msgpack false
71
+ #encoder yajl
68
72
  </match>
69
73
  ```
70
74
 
71
75
  ### Parameter
72
76
 
73
- * **host** (string) (optional): The hostname of PostgreSQL server
74
- * Default value: `localhost`.
75
- * **port** (integer) (optional): The port of PostgreSQL server
76
- * Default value: `5432`.
77
- * **sslmode** (enum) (optional): Set the sslmode to enable Eavesdropping protection/MITM protection. See [PostgreSQL Documentation](https://www.postgresql.org/docs/10/static/libpq-ssl.html) for more details.
78
- * Available values: disable, allow, prefer, require, verify-ca, verify-full
79
- * Default value: `prefer`.
80
- * **database** (string) (required): The database name to connect
81
- * **table** (string) (required): The table name to insert records
82
- * **user** (string) (optional): The user name to connect database
83
- * **password** (string) (optional): The password to connect database
84
- * **time_col** (string) (optional): The column name for the time
85
- * Default value: `time`.
86
- * **tag_col** (string) (optional): The column name for the tag
87
- * Default value: `tag`.
88
- * **record_col** (string) (optional): The column name for the record
89
- * Default value: `record`.
90
- * **msgpack** (bool) (optional): If true, insert records formatted as msgpack
91
- * **encoder** (enum) (optional): JSON encoder (yajl/json)
92
- * Available values: yajl, json
93
- * Default value: `yajl`.
77
+ |parameter|description|default|
78
+ |---|---|---|
79
+ |host|The hostname of PostgreSQL server|localhost|
80
+ |port|The port of PostgreSQL server|5432|
81
+ |sslmode|Set the sslmode to enable Eavesdropping protection/MITM protection. See [PostgreSQL Documentation](https://www.postgresql.org/docs/10/static/libpq-ssl.html) for more details. (`disable`, `allow`, `prefer`, `require`, `verify-ca`, `verify-full`)|`prefer`|
82
+ |database|The database name to connect||
83
+ |table|The table name to insert records||
84
+ |user|The user name to connect database|nil|
85
+ |password|The password to connect database|nil|
86
+ |time_col|The column name for the time|`time`|
87
+ |tag_col|The column name for the tag|`tag`|
88
+ |record_col|The column name for the record|`record`|
89
+ |msgpack|If true, insert records formatted as msgpack|`false`|
90
+ |encoder|JSON encoder (`yajl`, `json`)|`yajl`|
94
91
 
95
92
  ## Copyright
96
93
 
@@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "fluent-plugin-pgjson"
5
- s.version = "1.0.1"
5
+ s.version = "1.0.2"
6
6
  s.authors = ["OKUNO Akihiro"]
7
7
  s.email = ["choplin.choplin@gmail.com"]
8
8
  s.homepage = "https://github.com/fluent-plugins-nursery/fluent-plugin-pgjson"
@@ -19,4 +19,5 @@ Gem::Specification.new do |s|
19
19
  s.add_runtime_dependency "pg"
20
20
  s.add_development_dependency "test-unit", ">= 3.1.0"
21
21
  s.add_development_dependency "rake", ">= 11.0"
22
+ s.add_development_dependency "webrick"
22
23
  end
@@ -84,12 +84,16 @@ module Fluent::Plugin
84
84
 
85
85
  def write(chunk)
86
86
  init_connection
87
- @conn.exec("COPY #{@table} (#{@tag_col}, #{@time_col}, #{@record_col}) FROM STDIN WITH DELIMITER E'\\x01'")
88
87
  begin
88
+ @conn.exec("COPY #{@table} (#{@tag_col}, #{@time_col}, #{@record_col}) FROM STDIN WITH DELIMITER E'\\x01'")
89
89
  tag = chunk.metadata.tag
90
90
  chunk.msgpack_each do |time, record|
91
91
  @conn.put_copy_data "#{tag}\x01#{time}\x01#{record_value(record)}\n"
92
92
  end
93
+ rescue PG::UnableToSend
94
+ @conn.close()
95
+ @conn = nil
96
+ raise
93
97
  rescue => err
94
98
  errmsg = "%s while copy data: %s" % [ err.class.name, err.message ]
95
99
  @conn.put_copy_end( errmsg )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-pgjson
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - OKUNO Akihiro
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-29 00:00:00.000000000 Z
11
+ date: 2021-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -72,6 +72,20 @@ dependencies:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '11.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: webrick
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
75
89
  description: ''
76
90
  email:
77
91
  - choplin.choplin@gmail.com
@@ -79,8 +93,8 @@ executables: []
79
93
  extensions: []
80
94
  extra_rdoc_files: []
81
95
  files:
96
+ - ".github/workflows/linux.yml"
82
97
  - ".gitignore"
83
- - ".travis.yml"
84
98
  - Gemfile
85
99
  - LICENSE
86
100
  - README.md
@@ -94,7 +108,7 @@ homepage: https://github.com/fluent-plugins-nursery/fluent-plugin-pgjson
94
108
  licenses:
95
109
  - Apache-2.0
96
110
  metadata: {}
97
- post_install_message:
111
+ post_install_message:
98
112
  rdoc_options: []
99
113
  require_paths:
100
114
  - lib
@@ -109,8 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
125
  requirements: []
112
- rubygems_version: 3.0.3
113
- signing_key:
126
+ rubygems_version: 3.2.30
127
+ signing_key:
114
128
  specification_version: 4
115
129
  summary: Fluentd Output Plugin for PostgreSQL JSON Type.
116
130
  test_files:
data/.travis.yml DELETED
@@ -1,17 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - 2.4
5
- - 2.5
6
- - 2.6
7
- - 2.7.1
8
-
9
- addons:
10
- postgresql: "9.6"
11
-
12
- services:
13
- - postgresql
14
-
15
- before_script:
16
- - psql -c "create role fluentd with LOGIN CREATEDB password 'fluentd';" -U postgres
17
- - psql -c "create database pgjsontest owner fluentd encoding 'utf-8'" -U postgres