fluent-plugin-formatter-protobuf 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release-please.yml +48 -0
- data/.release-please-manifest.json +3 -0
- data/CHANGELOG.md +8 -0
- data/README.md +7 -6
- data/RELEASE.md +2 -7
- data/lib/fluent/plugin/formatter_protobuf.rb +20 -1
- data/lib/fluent/plugin/version.rb +1 -1
- data/release-please-config.json +13 -0
- data/test/integration/Gemfile.lock +2 -2
- data/test/plugin/test_formatter_protobuf.rb +31 -10
- metadata +6 -3
- data/.github/workflows/publish.yml +0 -96
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6218edd36cd2e7186b2def09700237885d5851931a15ad3859b8eecdc8fd1ca
|
4
|
+
data.tar.gz: f609d96e5a3dd326ee0cc5d9a9638942ed9f9f063f34bca7ad696176ed58f589
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de97c9eed15e2ff1f86a4042412ad59efedad063a6957f052828b5efd5a3e6c888e9a1aa3f2f0c4cc1b1c33b3906a48d91dbd4d1b8dd855ece6c24db2be2742d
|
7
|
+
data.tar.gz: 45365b906912baf789221d565b039a44a4c97ac596518da587778ece2e92856b027a6ac5768cfae8fd64c9dd5b4032195ba2fc874c73cb1b804b9c93286c7682
|
@@ -0,0 +1,48 @@
|
|
1
|
+
on:
|
2
|
+
push:
|
3
|
+
branches:
|
4
|
+
- main
|
5
|
+
name: release-please
|
6
|
+
jobs:
|
7
|
+
release-please:
|
8
|
+
environment: main
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
steps:
|
11
|
+
- uses: google-github-actions/release-please-action@v2
|
12
|
+
id: release
|
13
|
+
with:
|
14
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
15
|
+
release-type: ruby
|
16
|
+
version-file: "lib/fluent/plugin/version.rb"
|
17
|
+
|
18
|
+
- uses: actions/checkout@v2
|
19
|
+
|
20
|
+
- name: Set up Ruby 2.5
|
21
|
+
uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
bundler-cache: true
|
24
|
+
|
25
|
+
- name: Publish to GPR
|
26
|
+
run: |
|
27
|
+
mkdir -p $HOME/.gem
|
28
|
+
touch $HOME/.gem/credentials
|
29
|
+
chmod 0600 $HOME/.gem/credentials
|
30
|
+
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
31
|
+
gem build *.gemspec
|
32
|
+
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
33
|
+
env:
|
34
|
+
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
|
35
|
+
OWNER: ${{ github.repository_owner }}
|
36
|
+
if: ${{ steps.release.outputs.release_created }}
|
37
|
+
|
38
|
+
- name: Publish to RubyGems
|
39
|
+
run: |
|
40
|
+
mkdir -p $HOME/.gem
|
41
|
+
touch $HOME/.gem/credentials
|
42
|
+
chmod 0600 $HOME/.gem/credentials
|
43
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
44
|
+
gem build *.gemspec
|
45
|
+
gem push *.gem
|
46
|
+
env:
|
47
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
48
|
+
if: ${{ steps.release.outputs.release_created }}
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [0.3.0](https://www.github.com/fluent-plugins-nursery/fluent-plugin-formatter-protobuf/compare/v0.2.0...v0.3.0) (2022-01-13)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* Add new configuration - `format_field` ([797789b](https://www.github.com/fluent-plugins-nursery/fluent-plugin-formatter-protobuf/commit/797789b38d5a599c2c107979beb7edf66e384bd5))
|
data/README.md
CHANGED
@@ -88,12 +88,13 @@ This plugin only supports Protobuf v3.
|
|
88
88
|
|
89
89
|
## Configuration
|
90
90
|
|
91
|
-
|parameter| type | description
|
92
|
-
|
93
|
-
|class_name| string (required) | Ruby Protobuf class name. Used to encode into Protobuf binary
|
94
|
-
|decode_json| boolean (optional) | Serializes record from canonical proto3 JSON mapping (https://developers.google.com/protocol-buffers/docs/proto3#json) into binary
|
95
|
-
|
|
96
|
-
|
|
91
|
+
|parameter| type | description | default |
|
92
|
+
|---|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|
|
93
|
+
|class_name| string (required) | Ruby Protobuf class name. Used to encode into Protobuf binary ||
|
94
|
+
|decode_json| boolean (optional) | Serializes record from canonical proto3 JSON mapping (https://developers.google.com/protocol-buffers/docs/proto3#json) into binary | `false` |
|
95
|
+
|format_field| string (optional) | When defined, the plugin will only serialise the record in the given field rather than the whole record. This is potentially useful if you intend to use this formatter with the Kafka output plugin (https://github.com/fluent/fluent-plugin-kafka#output-plugin) for example, where your record contains a field to determine which Kafka topic to write to, or the Kafka headers to include, but you do not wish to include those data in the resulting proto3 binary. Defaults to serialising the entire record. | `''` |
|
96
|
+
|include_paths| array (required) | Generated Ruby Protobuf class files path | `[]` |
|
97
|
+
|require_method| string (optional) | Determine how to bring the generated Ruby Protobuf class files into scope. If your generated Ruby Protobuf class files are provided by a Ruby Gem, you may want to use 'require'. If you are providing the generated files as files, you may want to use 'require_relative' | `require` |
|
97
98
|
|
98
99
|
## Tips
|
99
100
|
|
data/RELEASE.md
CHANGED
@@ -1,9 +1,4 @@
|
|
1
1
|
# Release
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
1. Update `lib/fluent/plugin/version.rb`
|
7
|
-
2. Create a pull request and merge it into `main`
|
8
|
-
3. Manually creating a release on Github with a tag indicating the new version number e.g. `vMAJOR.MINOR.PATCH`
|
9
|
-
4. GitHub Actions will automatically run and publish to RubyGems and GitHub repository
|
3
|
+
This repository follow conventional commit and semantic versioning, and the release to RubyGems.org and GitHub Ruby
|
4
|
+
Repository is managed by [release-please](https://github.com/google-github-actions/release-please-action).
|
@@ -41,6 +41,19 @@ module Fluent
|
|
41
41
|
Serializes record from canonical proto3 JSON mapping (https://developers.google.com/protocol-buffers/docs/proto3#json) into binary'
|
42
42
|
DESC
|
43
43
|
|
44
|
+
config_param :format_field,
|
45
|
+
:string,
|
46
|
+
default: '',
|
47
|
+
desc: <<~DESC
|
48
|
+
When defined, the plugin will only serialise the record in the given field rather than the whole record.
|
49
|
+
This is potentially useful if you intend to use this formatter with the Kafka output plugin
|
50
|
+
(https://github.com/fluent/fluent-plugin-kafka#output-plugin) for example, where your record contains
|
51
|
+
a field to determine which Kafka topic to write to, or the Kafka headers to include, but you do not
|
52
|
+
wish to include those data in the resulting proto3 binary.
|
53
|
+
|
54
|
+
Defaults to serialising the whole record.
|
55
|
+
DESC
|
56
|
+
|
44
57
|
config_param :include_paths,
|
45
58
|
:array,
|
46
59
|
default: [],
|
@@ -73,7 +86,13 @@ module Fluent
|
|
73
86
|
end
|
74
87
|
|
75
88
|
def format(_tag, _time, record)
|
76
|
-
|
89
|
+
format_record = @format_field == '' ? record : record[@format_field]
|
90
|
+
|
91
|
+
protobuf_msg = if @decode_json
|
92
|
+
@protobuf_class.decode_json(Oj.dump(format_record))
|
93
|
+
else
|
94
|
+
@protobuf_class.new(format_record)
|
95
|
+
end
|
77
96
|
@protobuf_class.encode(protobuf_msg)
|
78
97
|
end
|
79
98
|
|
@@ -18,8 +18,8 @@ GEM
|
|
18
18
|
tzinfo-data (~> 1.0)
|
19
19
|
webrick (>= 1.4.2, < 1.8.0)
|
20
20
|
yajl-ruby (~> 1.0)
|
21
|
-
google-protobuf (3.19.
|
22
|
-
google-protobuf (3.19.
|
21
|
+
google-protobuf (3.19.2)
|
22
|
+
google-protobuf (3.19.2-x86_64-linux)
|
23
23
|
http_parser.rb (0.7.0)
|
24
24
|
msgpack (1.4.2)
|
25
25
|
serverengine (2.2.4)
|
@@ -51,21 +51,34 @@ class ProtobufFormatterTest < Test::Unit::TestCase
|
|
51
51
|
end
|
52
52
|
# rubocop:enable Metrics/BlockLength
|
53
53
|
|
54
|
-
stub_ruby_hash = { people
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
54
|
+
stub_ruby_hash = { 'people' => [{ 'name' => 'Masahiro', 'id' => 1337,
|
55
|
+
'email' => 'repeatedly _at_ gmail.com',
|
56
|
+
'last_updated' => {
|
57
|
+
'seconds' => 1_638_489_505,
|
58
|
+
'nanos' => 318_000_000
|
59
|
+
} }] }
|
60
60
|
# rubocop:disable Metrics/BlockLength
|
61
61
|
sub_test_case 'format' do
|
62
62
|
test 'encodes into Protobuf binary' do
|
63
63
|
formatter = create_formatter({ class_name: 'tutorial.AddressBook',
|
64
64
|
include_paths: VALID_INCLUDE_PATHS_ABSOLUTE })
|
65
65
|
|
66
|
+
formatted = formatter.format('some-tag', 1234, stub_ruby_hash)
|
67
|
+
address_book = Tutorial::AddressBook.new(stub_ruby_hash)
|
68
|
+
assert_equal(Tutorial::AddressBook.encode(address_book), formatted)
|
69
|
+
end
|
70
|
+
|
71
|
+
test 'encodes a particular field instead of the entire record if format_field is defined' do
|
72
|
+
formatter = create_formatter({ class_name: 'tutorial.AddressBook',
|
73
|
+
include_paths: VALID_INCLUDE_PATHS_ABSOLUTE,
|
74
|
+
format_field: 'data' })
|
75
|
+
|
66
76
|
formatted = formatter.format('some-tag', 1234,
|
67
|
-
{
|
68
|
-
|
77
|
+
{
|
78
|
+
'topic' => 'some-kafka-topic',
|
79
|
+
'headers' => {},
|
80
|
+
'data' => stub_ruby_hash
|
81
|
+
})
|
69
82
|
address_book = Tutorial::AddressBook.new(stub_ruby_hash)
|
70
83
|
assert_equal(Tutorial::AddressBook.encode(address_book), formatted)
|
71
84
|
end
|
@@ -76,8 +89,16 @@ class ProtobufFormatterTest < Test::Unit::TestCase
|
|
76
89
|
include_paths: VALID_INCLUDE_PATHS_ABSOLUTE })
|
77
90
|
|
78
91
|
formatted = formatter.format('some-tag', 1234,
|
79
|
-
{
|
80
|
-
|
92
|
+
{
|
93
|
+
'people' => [
|
94
|
+
{
|
95
|
+
'name' => 'Masahiro',
|
96
|
+
'id' => 1337,
|
97
|
+
'email' => 'repeatedly _at_ gmail.com',
|
98
|
+
'last_updated' => '2021-12-02T23:58:25.318Z'
|
99
|
+
}
|
100
|
+
]
|
101
|
+
})
|
81
102
|
|
82
103
|
address_book = Tutorial::AddressBook.new(stub_ruby_hash)
|
83
104
|
assert_equal(Tutorial::AddressBook.encode(address_book), formatted)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-formatter-protobuf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ray Tung
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -138,10 +138,12 @@ extra_rdoc_files: []
|
|
138
138
|
files:
|
139
139
|
- ".github/workflows/build-and-test.yml"
|
140
140
|
- ".github/workflows/codeql-analysis.yml"
|
141
|
-
- ".github/workflows/
|
141
|
+
- ".github/workflows/release-please.yml"
|
142
142
|
- ".gitignore"
|
143
|
+
- ".release-please-manifest.json"
|
143
144
|
- ".rubocop.yml"
|
144
145
|
- ".ruby-version"
|
146
|
+
- CHANGELOG.md
|
145
147
|
- Gemfile
|
146
148
|
- LICENSE
|
147
149
|
- README.md
|
@@ -152,6 +154,7 @@ files:
|
|
152
154
|
- fluent-plugin-formatter-protobuf.gemspec
|
153
155
|
- lib/fluent/plugin/formatter_protobuf.rb
|
154
156
|
- lib/fluent/plugin/version.rb
|
157
|
+
- release-please-config.json
|
155
158
|
- test/helper.rb
|
156
159
|
- test/integration/Gemfile
|
157
160
|
- test/integration/Gemfile.lock
|
@@ -1,96 +0,0 @@
|
|
1
|
-
name: Publish
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
tags:
|
6
|
-
- v0.*
|
7
|
-
|
8
|
-
jobs:
|
9
|
-
lint:
|
10
|
-
name: Lint
|
11
|
-
runs-on: ubuntu-latest
|
12
|
-
permissions:
|
13
|
-
packages: write
|
14
|
-
contents: read
|
15
|
-
|
16
|
-
steps:
|
17
|
-
- uses: actions/checkout@v2
|
18
|
-
- name: Set up Ruby 2.5
|
19
|
-
uses: ruby/setup-ruby@v1
|
20
|
-
with:
|
21
|
-
bundler-cache: true
|
22
|
-
- name: "Unit test"
|
23
|
-
run: "bundle exec rake lint:check"
|
24
|
-
|
25
|
-
test:
|
26
|
-
name: Unit test
|
27
|
-
runs-on: ubuntu-latest
|
28
|
-
permissions:
|
29
|
-
packages: write
|
30
|
-
contents: read
|
31
|
-
|
32
|
-
steps:
|
33
|
-
- uses: actions/checkout@v2
|
34
|
-
- name: Set up Ruby 2.5
|
35
|
-
uses: ruby/setup-ruby@v1
|
36
|
-
with:
|
37
|
-
bundler-cache: true
|
38
|
-
- name: "Unit test"
|
39
|
-
run: "bundle exec rake test:unit"
|
40
|
-
|
41
|
-
publish-to-gpr:
|
42
|
-
needs:
|
43
|
-
- lint
|
44
|
-
- test
|
45
|
-
name: Build + Publish to GPR
|
46
|
-
runs-on: ubuntu-latest
|
47
|
-
permissions:
|
48
|
-
packages: write
|
49
|
-
contents: read
|
50
|
-
|
51
|
-
steps:
|
52
|
-
- uses: actions/checkout@v2
|
53
|
-
- name: Set up Ruby 2.5
|
54
|
-
uses: ruby/setup-ruby@v1
|
55
|
-
with:
|
56
|
-
bundler-cache: true
|
57
|
-
|
58
|
-
- name: Publish to GPR
|
59
|
-
run: |
|
60
|
-
mkdir -p $HOME/.gem
|
61
|
-
touch $HOME/.gem/credentials
|
62
|
-
chmod 0600 $HOME/.gem/credentials
|
63
|
-
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
64
|
-
gem build *.gemspec
|
65
|
-
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
66
|
-
env:
|
67
|
-
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
|
68
|
-
OWNER: ${{ github.repository_owner }}
|
69
|
-
|
70
|
-
publish-to-ruby-gems:
|
71
|
-
needs:
|
72
|
-
- lint
|
73
|
-
- test
|
74
|
-
name: Build + Publish to RubyGems
|
75
|
-
runs-on: ubuntu-latest
|
76
|
-
permissions:
|
77
|
-
packages: write
|
78
|
-
contents: read
|
79
|
-
|
80
|
-
steps:
|
81
|
-
- uses: actions/checkout@v2
|
82
|
-
- name: Set up Ruby 2.5
|
83
|
-
uses: ruby/setup-ruby@v1
|
84
|
-
with:
|
85
|
-
bundler-cache: true
|
86
|
-
|
87
|
-
- name: Publish to RubyGems
|
88
|
-
run: |
|
89
|
-
mkdir -p $HOME/.gem
|
90
|
-
touch $HOME/.gem/credentials
|
91
|
-
chmod 0600 $HOME/.gem/credentials
|
92
|
-
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
93
|
-
gem build *.gemspec
|
94
|
-
gem push *.gem
|
95
|
-
env:
|
96
|
-
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|