fluent-plugin-parser-protobuf 0.1.1 → 0.1.2

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: '02618818d401d30bc764e685463dba4ecbd1c81e06c385353116c87c0784009c'
4
- data.tar.gz: 2022746e1ee17174e20a105d58c4464be603c50d4a9a80f4cceadc4cb0fed5a3
3
+ metadata.gz: 63a87edc22262b37fa780ce69865de8a2be6bfb692c557f0e48926c866febb92
4
+ data.tar.gz: 458cd65c672a962359e809eaee8d0de290fcebc875d23e3a54140713139f7d58
5
5
  SHA512:
6
- metadata.gz: e65e1baf904aea0f8f6df43319d27f653d0087f49a96102ed2a840bff80f102f2d10c1e855787d3ce14f1cf872ec572c918205a140d66f042976e741bff2a33e
7
- data.tar.gz: be9cb26df285b531085ae5fa96fa2ec43694e0ef9c293a49d6d326f723dd850b4b9504079d0b7e7e0d51bf28cf9c2e5fdc037f3583804a1187d930564d24a67f
6
+ metadata.gz: 8f84f1c6e697e1a44fcdb2b30add9196c2d34004062393a1552354021a4e7d743d3b63c748f03d4c0179bcf11abef20333a486f88b553b58cc7ae99979c1e695
7
+ data.tar.gz: a57e068998c92a8fc43052a8161e0793a28f03182371b6805cc8e134c9922bba7564b22d8b35196627dd92eaf04e6c2f11376d7401303932111e4ab8a58a1683
@@ -1,4 +1,9 @@
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.2
4
+ - Add invalid parameters combination checker
5
+ - Follow Fluentd v1 parser requirements
6
+ - Introduce suppressing to decode error parameter
2
7
 
3
8
  ### v0.1.1
4
9
  - Fix invalid ConfigError usages
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,7 @@ 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.
76
78
 
77
79
  ## LICENSE
78
80
 
@@ -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.2"
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,9 +23,9 @@ 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.0'
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"
@@ -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,14 @@
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.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Hatake
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-01 00:00:00.000000000 Z
11
+ date: 2020-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-unit
@@ -92,14 +92,14 @@ files:
92
92
  - bin/setup
93
93
  - fluent-plugin-parser-protobuf.gemspec
94
94
  - lib/fluent/plugin/parser_protobuf.rb
95
- homepage: https://github.com/cosmo0920/fluent-plugin-parser-protobuf
95
+ homepage: https://github.com/fluent-plugins-nursery/fluent-plugin-parser-protobuf
96
96
  licenses:
97
97
  - Apache-2.0
98
98
  metadata:
99
99
  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
100
+ homepage_uri: https://github.com/fluent-plugins-nursery/fluent-plugin-parser-protobuf
101
+ source_code_uri: https://github.com/fluent-plugins-nursery/fluent-plugin-parser-protobuf
102
+ changelog_uri: https://github.com/fluent-plugins-nursery/fluent-plugin-parser-protobuf/blob/master/CHANGELOG.md
103
103
  post_install_message:
104
104
  rdoc_options: []
105
105
  require_paths: