fluent-plugin-pgjson 1.0.1 → 1.0.3

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: eb19054f9e9fef7f00b8af99540756d9e8bfedc7a656dc2d56f6448ba75aaccf
4
+ data.tar.gz: 723274d0c3b213c1f2846ecabf1f8c99dcf04f0b68ab9157890b7552276b0210
5
5
  SHA512:
6
- metadata.gz: defaa3ee2680a7927e36f4bb0b52013ee296ae31da2cc554a6688802c3d809bc6495914bc0f7f2c01040f972f962fa68d42b81610d873638be55f695be0f0364
7
- data.tar.gz: f733dd18d69b42b4d2bdd5aba65c071b0200e6ec5b64cb7022e30ce45b083630a19454a52b54d8838cd81a9569375037ac501a1a2b938701dd7d29f79849df30
6
+ metadata.gz: 75262bb406e5efd5b0eac23b8d06457d4598cafd5bd138bf5cc23ebcafa3922bcc2985f62cda5218f02ebb41706e46188c362a98ba31e872c95029f23a8e7c8a
7
+ data.tar.gz: d585c960134d86bac1346fe30aaa3696237e4371ce687179c2999881236b0443955151f8f4b0e713946a388a5c9f29d20db64e9f4b9c80dd1e77902019b7759e
@@ -0,0 +1,23 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: 'github-actions'
4
+ directory: '/'
5
+ schedule:
6
+ interval: 'monthly'
7
+ groups:
8
+ # PR: "Security update [package] from [old] to [new]"
9
+ # This PR should be merged in hurry
10
+ security-updates:
11
+ applies-to: security-updates
12
+ patterns:
13
+ - '*'
14
+
15
+ # PR: "Bump [package] from [old] to [new]"
16
+ # No need to be merged this PR in hurry. It is enough to merge
17
+ # once in a month.
18
+ monthly-updates:
19
+ applies-to: version-updates
20
+ patterns:
21
+ - '*'
22
+ # Allow to create PR both of security and normal updates.
23
+ open-pull-requests-limit: 1
@@ -0,0 +1,58 @@
1
+ name: linux
2
+ on:
3
+ push:
4
+ branches: [master]
5
+ pull_request:
6
+ branches: [master]
7
+ schedule:
8
+ - cron: '0 0 1 * *'
9
+ jobs:
10
+ ruby-versions:
11
+ uses: ruby/actions/.github/workflows/ruby_versions.yml@master
12
+ with:
13
+ engine: cruby
14
+ min_version: 3.2
15
+ build:
16
+ needs: ruby-versions
17
+ runs-on: ${{ matrix.os }}
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
22
+ exclude:
23
+ - ruby: head
24
+ postgres: [ '14', '15', '16', '17', '18' ]
25
+ os:
26
+ - ubuntu-latest
27
+ services:
28
+ postgres:
29
+ image: postgres:${{ matrix.postgres }}
30
+ ports:
31
+ - 5432:5432
32
+ env:
33
+ POSTGRES_USER: postgres
34
+ POSTGRES_PASSWORD: password
35
+ POSTGRES_DB: test
36
+ options: >-
37
+ --health-cmd pg_isready
38
+ --health-interval 10s
39
+ --health-timeout 5s
40
+ --health-retries 5
41
+ name: Ruby ${{ matrix.ruby }} unit testing with PostgreSQL ${{ matrix.postgres }}
42
+ steps:
43
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
44
+ - uses: ruby/setup-ruby@145243922b4465b78e04dd66294782c7de45901f # v1.345.0
45
+ with:
46
+ ruby-version: ${{ matrix.ruby }}
47
+ bundler-cache: true
48
+ - name: prepare database
49
+ env:
50
+ PGPASSWORD: password
51
+ run: |
52
+ psql -h localhost -p 5432 -U postgres -c "create role fluentd with LOGIN CREATEDB password 'fluentd';"
53
+ psql -h localhost -p 5432 -U postgres -c "create database pgjsontest owner fluentd encoding 'utf-8'" -U postgres
54
+ - name: unit testing
55
+ env:
56
+ CI: true
57
+ run: |
58
+ 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/actions/workflows/linux.yml/badge.svg)](https://github.com/fluent-plugins-nursery/fluent-plugin-pgjson/actions/workflows/linux.yml)
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 json
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`) Starting from v1.0.3, `yajl` is no longer available and internally defaults to `json`|`json`|
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.3"
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
@@ -1,6 +1,5 @@
1
1
  require "fluent/plugin/output"
2
2
  require "pg"
3
- require "yajl"
4
3
  require "json"
5
4
 
6
5
  module Fluent::Plugin
@@ -34,7 +33,7 @@ module Fluent::Plugin
34
33
  desc "If true, insert records formatted as msgpack"
35
34
  config_param :msgpack, :bool, default: false
36
35
  desc "JSON encoder (yajl/json)"
37
- config_param :encoder, :enum, list: [:yajl, :json], default: :yajl
36
+ config_param :encoder, :enum, list: [:yajl, :json], default: :json # NOTE: Contains yajl for backward compatibility
38
37
 
39
38
  config_param :time_format, :string, default: "%F %T.%N %z"
40
39
 
@@ -56,7 +55,8 @@ module Fluent::Plugin
56
55
  end
57
56
  @encoder = case @encoder
58
57
  when :yajl
59
- Yajl
58
+ log.info "encoder 'yajl' is deprecated. Please use 'json' instead."
59
+ JSON
60
60
  when :json
61
61
  JSON
62
62
  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 )
@@ -17,7 +17,7 @@ class PgJsonOutputTest < Test::Unit::TestCase
17
17
  TIME_COL = "time"
18
18
  TAG_COL = "tag"
19
19
  RECORD_COL = "record"
20
- ENCODER = Yajl
20
+ ENCODER = JSON
21
21
 
22
22
  CONFIG = %[
23
23
  @type pgjson
metadata CHANGED
@@ -1,14 +1,13 @@
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.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - OKUNO Akihiro
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2020-07-29 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: fluentd
@@ -72,6 +71,20 @@ dependencies:
72
71
  - - ">="
73
72
  - !ruby/object:Gem::Version
74
73
  version: '11.0'
74
+ - !ruby/object:Gem::Dependency
75
+ name: webrick
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ type: :development
82
+ prerelease: false
83
+ version_requirements: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
75
88
  description: ''
76
89
  email:
77
90
  - choplin.choplin@gmail.com
@@ -79,8 +92,9 @@ executables: []
79
92
  extensions: []
80
93
  extra_rdoc_files: []
81
94
  files:
95
+ - ".github/dependabot.yml"
96
+ - ".github/workflows/linux.yml"
82
97
  - ".gitignore"
83
- - ".travis.yml"
84
98
  - Gemfile
85
99
  - LICENSE
86
100
  - README.md
@@ -94,7 +108,6 @@ 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:
98
111
  rdoc_options: []
99
112
  require_paths:
100
113
  - lib
@@ -109,8 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
122
  - !ruby/object:Gem::Version
110
123
  version: '0'
111
124
  requirements: []
112
- rubygems_version: 3.0.3
113
- signing_key:
125
+ rubygems_version: 4.0.20
114
126
  specification_version: 4
115
127
  summary: Fluentd Output Plugin for PostgreSQL JSON Type.
116
128
  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