fluent-plugin-parser-protobuf 0.1.1 → 0.1.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: '02618818d401d30bc764e685463dba4ecbd1c81e06c385353116c87c0784009c'
4
- data.tar.gz: 2022746e1ee17174e20a105d58c4464be603c50d4a9a80f4cceadc4cb0fed5a3
3
+ metadata.gz: 385c93dafa9ad31590da8712ce4377ec949af505ac3abc063e58b381bb5e6677
4
+ data.tar.gz: fbec46e476ab775dd3563640e8c11ca73b2dfb5b6c4f9445abcec30d16362273
5
5
  SHA512:
6
- metadata.gz: e65e1baf904aea0f8f6df43319d27f653d0087f49a96102ed2a840bff80f102f2d10c1e855787d3ce14f1cf872ec572c918205a140d66f042976e741bff2a33e
7
- data.tar.gz: be9cb26df285b531085ae5fa96fa2ec43694e0ef9c293a49d6d326f723dd850b4b9504079d0b7e7e0d51bf28cf9c2e5fdc037f3583804a1187d930564d24a67f
6
+ metadata.gz: 486f9aee1f52516e43b4a0bcc607cd243e26b0f8b07910de3ee4c7e321af433d65e23b2228c99ef1aa0a925775ac661e413d123ed7111e368e93e57df747a470
7
+ data.tar.gz: 99c29305690b646456eba4133418faefaf40ad0a152508ef06221068795882b74b3d419d55c91b4301aa5575f8ec127633563bc647dd750539c439202b7a56c1
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: 'github-actions'
4
+ directory: '/'
5
+ schedule:
6
+ interval: 'monthly'
@@ -8,19 +8,18 @@ jobs:
8
8
  strategy:
9
9
  fail-fast: false
10
10
  matrix:
11
- ruby: [ '2.4', '2.5', '2.6' ]
11
+ ruby: [ '2.7', '3.0', '3.1', '3.2', '3.3', '3.4', '4.0' ]
12
12
  os:
13
13
  - ubuntu-latest
14
14
  name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }}
15
15
  steps:
16
- - uses: actions/checkout@v2
17
- - uses: ruby/setup-ruby@v1
16
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
17
+ - uses: ruby/setup-ruby@6ca151fd1bfcfd6fe0c4eb6837eb0584d0134a0c # v1.290.0
18
18
  with:
19
19
  ruby-version: ${{ matrix.ruby }}
20
+ bundler-cache: true
20
21
  - name: unit testing
21
22
  env:
22
23
  CI: true
23
24
  run: |
24
- gem install bundler rake
25
- bundle install --jobs 4 --retry 3
26
25
  bundle exec rake test
@@ -8,19 +8,18 @@ jobs:
8
8
  strategy:
9
9
  fail-fast: false
10
10
  matrix:
11
- ruby: [ '2.4', '2.5', '2.6' ]
11
+ ruby: [ '2.7', '3.0', '3.1', '3.2', '3.3', '3.4', '4.0' ]
12
12
  os:
13
13
  - macOS-latest
14
14
  name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }}
15
15
  steps:
16
- - uses: actions/checkout@v2
17
- - uses: ruby/setup-ruby@v1
16
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
17
+ - uses: ruby/setup-ruby@6ca151fd1bfcfd6fe0c4eb6837eb0584d0134a0c # v1.290.0
18
18
  with:
19
19
  ruby-version: ${{ matrix.ruby }}
20
+ bundler-cache: true
20
21
  - name: unit testing
21
22
  env:
22
23
  CI: true
23
24
  run: |
24
- gem install bundler rake
25
- bundle install --jobs 4 --retry 3
26
25
  bundle exec rake test
@@ -8,19 +8,18 @@ jobs:
8
8
  strategy:
9
9
  fail-fast: false
10
10
  matrix:
11
- ruby: [ '2.4', '2.5', '2.6' ]
11
+ ruby: [ '2.7', '3.0', '3.1', '3.2', '3.3', '3.4', '4.0' ]
12
12
  os:
13
13
  - windows-latest
14
14
  name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }}
15
15
  steps:
16
- - uses: actions/checkout@v2
17
- - uses: ruby/setup-ruby@v1
16
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
17
+ - uses: ruby/setup-ruby@6ca151fd1bfcfd6fe0c4eb6837eb0584d0134a0c # v1.290.0
18
18
  with:
19
19
  ruby-version: ${{ matrix.ruby }}
20
+ bundler-cache: true
20
21
  - name: unit testing
21
22
  env:
22
23
  CI: true
23
24
  run: |
24
- gem install bundler rake
25
- bundle install --jobs 4 --retry 3
26
25
  ridk exec bundle exec rake test
data/CHANGELOG.md CHANGED
@@ -1,4 +1,14 @@
1
- ## Changelog [[tags]](https://github.com/cosmo0920/fluent-plugin-parser-protobuf/tags)
1
+ ## Changelog [[tags]](https://github.com/fluent-plugins-nursery/fluent-plugin-parser-protobuf/tags)
2
+
3
+ ### v0.1.3
4
+ - gem: add racc dependency for Ruby 3.3+
5
+ - Gemfile: Remove rake gem version dependency
6
+ - gem: update test-unit dependency
7
+
8
+ ### v0.1.2
9
+ - Add invalid parameters combination checker
10
+ - Follow Fluentd v1 parser requirements
11
+ - Introduce suppressing to decode error parameter
2
12
 
3
13
  ### v0.1.1
4
14
  - Fix invalid ConfigError usages
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source "https://rubygems.org"
3
3
  # Specify your gem's dependencies in fluent-plugin-parser-protobuf.gemspec
4
4
  gemspec
5
5
 
6
- gem "rake", "~> 12.0"
6
+ gem "rake"
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # fluent-plugin-parser-protobuf
2
2
 
3
- ![Testing on Windows](https://github.com/cosmo0920/fluent-plugin-parser-protobuf/workflows/Testing%20on%20Windows/badge.svg?branch=master)
4
- ![Testing on macOS](https://github.com/cosmo0920/fluent-plugin-parser-protobuf/workflows/Testing%20on%20macOS/badge.svg?branch=master)
5
- ![Testing on Ubuntu](https://github.com/cosmo0920/fluent-plugin-parser-protobuf/workflows/Testing%20on%20Ubuntu/badge.svg?branch=master)
3
+ ![Testing on Windows](https://github.com/fluent-plugins-nursery/fluent-plugin-parser-protobuf/workflows/Testing%20on%20Windows/badge.svg?branch=master)
4
+ ![Testing on macOS](https://github.com/fluent-plugins-nursery/fluent-plugin-parser-protobuf/workflows/Testing%20on%20macOS/badge.svg?branch=master)
5
+ ![Testing on Ubuntu](https://github.com/fluent-plugins-nursery/fluent-plugin-parser-protobuf/workflows/Testing%20on%20Ubuntu/badge.svg?branch=master)
6
6
 
7
7
  Fluentd parser plugin for [Protocol Buffers](https://developers.google.com/protocol-buffers/docs/overview).
8
8
 
@@ -41,6 +41,7 @@ Users should prepare protocol buffers with the following compilers:
41
41
  class_file /path/to/your/protobuf/class_file_pb.rb
42
42
  class_name Your.Protobuf.Class.Name # For protobuf3
43
43
  protobuf_version protobuf3
44
+ # suppress_decoding_error false
44
45
  # include_paths [/path/to/your/protobuf/class_file_pb.rb, /path/to/your/protobuf/class_file2_pb.rb, ...]
45
46
  </parse>
46
47
  ```
@@ -60,6 +61,7 @@ class_name Your.Protobuf.Class.Name
60
61
  class_file /path/to/your/protobuf/class_file.pb.rb
61
62
  class_name Your::Protobuf::Class::Name # For protobuf2
62
63
  protobuf_version protobuf2
64
+ # suppress_decoding_error false
63
65
  # include_paths [/path/to/your/protobuf/class_file.pb.rb, /path/to/your/protobuf/class_file2.pb.rb, ...]
64
66
  </parse>
65
67
  ```
@@ -72,7 +74,11 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
72
74
 
73
75
  ## Contributing
74
76
 
75
- Bug reports and pull requests are welcome on GitHub at https://github.com/cosmo0920/fluent-plugin-parser-protobuf.
77
+ Bug reports and pull requests are welcome on GitHub at https://github.com/fluent-plugins-nursery/fluent-plugin-parser-protobuf.
78
+
79
+ ## Articles
80
+
81
+ * FluentdのInputプラグインでProtocol Buffersを扱う -- ククログ https://www.clear-code.com/blog/2020/6/4.html (ja)
76
82
 
77
83
  ## LICENSE
78
84
 
@@ -1,19 +1,19 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "fluent-plugin-parser-protobuf"
3
- spec.version = "0.1.1"
3
+ spec.version = "0.1.3"
4
4
  spec.authors = ["Hiroshi Hatake"]
5
5
  spec.email = ["cosmo0920.wp@gmail.com"]
6
6
 
7
7
  spec.summary = %q{Protobuf parser for Fluentd.}
8
8
  spec.description = %q{Protobuf parser for Fluentd.}
9
- spec.homepage = "https://github.com/cosmo0920/fluent-plugin-parser-protobuf"
9
+ spec.homepage = "https://github.com/fluent-plugins-nursery/fluent-plugin-parser-protobuf"
10
10
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
11
11
 
12
12
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
13
13
 
14
14
  spec.metadata["homepage_uri"] = spec.homepage
15
- spec.metadata["source_code_uri"] = "https://github.com/cosmo0920/fluent-plugin-parser-protobuf"
16
- spec.metadata["changelog_uri"] = "https://github.com/cosmo0920/fluent-plugin-parser-protobuf/blob/master/CHANGELOG.md"
15
+ spec.metadata["source_code_uri"] = "https://github.com/fluent-plugins-nursery/fluent-plugin-parser-protobuf"
16
+ spec.metadata["changelog_uri"] = "https://github.com/fluent-plugins-nursery/fluent-plugin-parser-protobuf/blob/master/CHANGELOG.md"
17
17
 
18
18
  # Specify which files should be added to the gem when it is released.
19
19
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -23,10 +23,12 @@ Gem::Specification.new do |spec|
23
23
  spec.bindir = "exe"
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ["lib"]
26
- spec.add_development_dependency 'test-unit', '~> 3.3.0'
27
26
  spec.license = "Apache-2.0"
28
27
 
28
+ spec.add_development_dependency 'test-unit', '~> 3.3'
29
29
  spec.add_runtime_dependency "fluentd", [">= 1.0", "< 2"]
30
30
  spec.add_runtime_dependency "google-protobuf", ["~> 3.12"]
31
31
  spec.add_runtime_dependency "ruby-protocol-buffers"
32
+ spec.add_runtime_dependency "webrick"
33
+ spec.add_runtime_dependency "racc"
32
34
  end
@@ -11,15 +11,23 @@ module Fluent
11
11
  class ProtobufParser < Parser
12
12
  Plugin.register_parser('protobuf', self)
13
13
 
14
- class Error < StandardError; end
15
-
16
14
  config_param :include_paths, :array, default: []
17
15
  config_param :class_file, :string, default: nil
18
16
  config_param :protobuf_version, :enum, list: [:protobuf2, :protobuf3], default: :protobuf3
19
17
  config_param :class_name, :string
18
+ config_param :suppress_decoding_error, :bool, default: false
20
19
 
21
20
  def configure(conf)
22
21
  super
22
+
23
+ if !@include_paths.empty? && !@class_file.nil?
24
+ raise Fluent::ConfigError, "Cannot use `include_paths` and `class_file` at the same time."
25
+ end
26
+
27
+ if @include_paths.empty? && @class_file.nil?
28
+ raise Fluent::ConfigError, "Need to specify `include_paths` or `class_file`."
29
+ end
30
+
23
31
  loading_required = Google::Protobuf::DescriptorPool.generated_pool.lookup(class_name).nil?
24
32
 
25
33
  load_protobuf_class(@class_file) if loading_required && @class_file
@@ -27,25 +35,39 @@ module Fluent
27
35
  include_paths.each {|path| load_protobuf_definition(path)} if !include_paths.empty? && loading_required
28
36
 
29
37
  if @protobuf_version == :protobuf2
30
- @protobuf_descriptor = create_prptobuf2_instance(@class_name)
38
+ @protobuf_descriptor = create_protobuf2_instance(@class_name)
31
39
  elsif @protobuf_version == :protobuf3
32
40
  @protobuf_descriptor = Google::Protobuf::DescriptorPool.generated_pool.lookup(@class_name).msgclass
33
41
  end
34
42
  end
35
43
 
44
+ def parser_type
45
+ :binary
46
+ end
47
+
36
48
  def parse(binary)
37
- if @protobuf_version == :protobuf3
38
- decoded = @protobuf_descriptor.decode(binary.to_s)
39
- time = @estimate_current_event ? Fluent::EventTime.now : nil
40
- yield time, decoded.to_h
41
- elsif @protobuf_version == :protobuf2
42
- decoded = @protobuf_descriptor.parse(binary.to_s)
43
- time = @estimate_current_event ? Fluent::EventTime.now : nil
44
- yield time, decoded.to_hash
49
+ begin
50
+ if @protobuf_version == :protobuf3
51
+ decoded = @protobuf_descriptor.decode(binary.to_s)
52
+ time = @estimate_current_event ? Fluent::EventTime.now : nil
53
+ yield time, decoded.to_h
54
+ elsif @protobuf_version == :protobuf2
55
+ decoded = @protobuf_descriptor.parse(binary.to_s)
56
+ time = @estimate_current_event ? Fluent::EventTime.now : nil
57
+ yield time, decoded.to_hash
58
+ end
59
+ rescue => e
60
+ log.warn("Couldn't decode protobuf: #{e.inspect}, message: #{binary}")
61
+ if @suppress_decoding_error
62
+ yield nil, nil
63
+ else
64
+ raise e
65
+ end
45
66
  end
46
67
  end
68
+ alias parse_partial_data parse
47
69
 
48
- def create_prptobuf2_instance(class_name)
70
+ def create_protobuf2_instance(class_name)
49
71
  unless Object.const_defined?(class_name)
50
72
  raise Fluent::ConfigError, "Cannot find class #{class_name}."
51
73
  else
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-parser-protobuf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Hatake
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2020-06-01 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: test-unit
@@ -16,14 +15,14 @@ dependencies:
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: 3.3.0
18
+ version: '3.3'
20
19
  type: :development
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: 3.3.0
25
+ version: '3.3'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: fluentd
29
28
  requirement: !ruby/object:Gem::Requirement
@@ -72,6 +71,34 @@ dependencies:
72
71
  - - ">="
73
72
  - !ruby/object:Gem::Version
74
73
  version: '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: :runtime
82
+ prerelease: false
83
+ version_requirements: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ - !ruby/object:Gem::Dependency
89
+ name: racc
90
+ requirement: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ type: :runtime
96
+ prerelease: false
97
+ version_requirements: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
75
102
  description: Protobuf parser for Fluentd.
76
103
  email:
77
104
  - cosmo0920.wp@gmail.com
@@ -79,6 +106,7 @@ executables: []
79
106
  extensions: []
80
107
  extra_rdoc_files: []
81
108
  files:
109
+ - ".github/dependabot.yml"
82
110
  - ".github/workflows/linux.yml"
83
111
  - ".github/workflows/macos.yml"
84
112
  - ".github/workflows/windows.yml"
@@ -92,15 +120,14 @@ files:
92
120
  - bin/setup
93
121
  - fluent-plugin-parser-protobuf.gemspec
94
122
  - lib/fluent/plugin/parser_protobuf.rb
95
- homepage: https://github.com/cosmo0920/fluent-plugin-parser-protobuf
123
+ homepage: https://github.com/fluent-plugins-nursery/fluent-plugin-parser-protobuf
96
124
  licenses:
97
125
  - Apache-2.0
98
126
  metadata:
99
127
  allowed_push_host: https://rubygems.org
100
- homepage_uri: https://github.com/cosmo0920/fluent-plugin-parser-protobuf
101
- source_code_uri: https://github.com/cosmo0920/fluent-plugin-parser-protobuf
102
- changelog_uri: https://github.com/cosmo0920/fluent-plugin-parser-protobuf/blob/master/CHANGELOG.md
103
- post_install_message:
128
+ homepage_uri: https://github.com/fluent-plugins-nursery/fluent-plugin-parser-protobuf
129
+ source_code_uri: https://github.com/fluent-plugins-nursery/fluent-plugin-parser-protobuf
130
+ changelog_uri: https://github.com/fluent-plugins-nursery/fluent-plugin-parser-protobuf/blob/master/CHANGELOG.md
104
131
  rdoc_options: []
105
132
  require_paths:
106
133
  - lib
@@ -115,8 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
142
  - !ruby/object:Gem::Version
116
143
  version: '0'
117
144
  requirements: []
118
- rubygems_version: 3.0.3
119
- signing_key:
145
+ rubygems_version: 4.0.6
120
146
  specification_version: 4
121
147
  summary: Protobuf parser for Fluentd.
122
148
  test_files: []