fluent-plugin-reemit 0.2.1 → 0.3.0

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
  SHA1:
3
- metadata.gz: 0404160cd5a1c4c5b048ff0dccc853242ed44299
4
- data.tar.gz: 1d832c567318c7d268fcc2e7e764a439f1b422fd
3
+ metadata.gz: 4694b1e10321c8954b685c7d010244e78e7e953d
4
+ data.tar.gz: 5a1905a04b7fa654df1397cccc19671f0ded31b2
5
5
  SHA512:
6
- metadata.gz: 182e124f72351c76ef85a86f2ed51a7f50247504f174617120f89eb62a7eba391a457c67f70773b3b0b2cb5c2b6fcb83fccffa56608be371f9813adedd4f809b
7
- data.tar.gz: e5c17f6c93b8e74a0c3cfc48cf6c9b9246cd52a04628e9f31fbecbe5e1da8b995af85c46a7bb929364db3edb481a17650f01577107dab983e619d7fd9d611dbf
6
+ metadata.gz: 5af41dc4e9b4608dedd759c8f2110797c94500b3b9487d31f4921a2b868c0f11fe24c9df54dbc36904fc902ddda4a5db9e9470da3c6803b8fc457921a326802c
7
+ data.tar.gz: 5a7de06331278710042bfb6379000ba84f2079849c7d4691473edd98ca81a50f84f01137ed9ef5244e4156fa866a940735780fddf47e05f87d12f3837e361c02
data/.gitignore CHANGED
@@ -3,7 +3,7 @@
3
3
  #*
4
4
  *~
5
5
  .bundle
6
- Gemfile.lock
6
+ *.lock
7
7
  .rbenv-version
8
8
  vendor
9
9
  doc/*
@@ -1,7 +1,10 @@
1
1
  rvm:
2
- - 1.9.3
3
- - 2.0.0
4
- - 2.1
2
+ - 2.1.*
3
+ - 2.2.*
4
+ - 2.3.0
5
5
  gemfile:
6
6
  - Gemfile
7
7
  - Gemfile.v0.12
8
+ - Gemfile.v0.10
9
+ before_install:
10
+ - gem update bundler
@@ -1,3 +1,9 @@
1
+ ## 0.3.0 (2017/09/13)
2
+
3
+ Enhancements:
4
+
5
+ * Support v0.14
6
+
1
7
  ## 0.2.1 (2015/08/11)
2
8
 
3
9
  Fixes:
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+ gem 'fluent-plugin-flowcounter' # for examples
5
+ gem 'fluentd', git: 'https://github.com/fluent/fluentd', branch: 'v0.10'
@@ -2,4 +2,4 @@ source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
4
  gem 'fluent-plugin-flowcounter' # for examples
5
- gem 'fluentd', git: 'https://github.com/fluent/fluentd'
5
+ gem 'fluentd', git: 'https://github.com/fluent/fluentd', branch: 'v0.12'
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = "fluent-plugin-reemit"
6
- gem.version = "0.2.1"
6
+ gem.version = "0.3.0"
7
7
  gem.authors = ["Naotoshi Seo"]
8
8
  gem.email = "sonots@gmail.com"
9
9
  gem.homepage = "https://github.com/sonots/fluent-plugin-reemit"
@@ -22,4 +22,5 @@ Gem::Specification.new do |gem|
22
22
  gem.add_development_dependency "rspec"
23
23
  gem.add_development_dependency "pry"
24
24
  gem.add_development_dependency "pry-nav"
25
+ gem.add_development_dependency "test-unit"
25
26
  end
@@ -1,4 +1,7 @@
1
- require 'fluent/event_router'
1
+ require 'fluent/version'
2
+ if Fluent::VERSION > '0.12'
3
+ require 'fluent/event_router'
4
+ end
2
5
 
3
6
  module Fluent
4
7
  class ReemitOutput < Output
@@ -15,9 +18,14 @@ module Fluent
15
18
 
16
19
  def start
17
20
  super
21
+ event_router = Engine.instance_variable_get(:@event_router)
18
22
  @router =
19
- if Engine.instance_variable_get(:@event_router)
20
- V12EventRouter.new(self)
23
+ if event_router
24
+ if v14?(event_router)
25
+ V14EventRouter.new(self)
26
+ else
27
+ V12EventRouter.new(self)
28
+ end
21
29
  else
22
30
  V10Engine.new(self)
23
31
  end
@@ -30,6 +38,11 @@ module Fluent
30
38
  log.warn "reemit: #{e.class} #{e.message} #{e.backtrace.first}"
31
39
  end
32
40
 
41
+ def v14?(event_router)
42
+ default_collector = event_router.instance_variable_get(:@default_collector)
43
+ default_collector.respond_to?(:emit_events)
44
+ end
45
+
33
46
  def included?(collector)
34
47
  return false if collector.nil?
35
48
  if collector == self
@@ -72,9 +85,8 @@ module Fluent
72
85
  end
73
86
 
74
87
  def find(tag)
75
- # we want to reemit to the next match after this reemit
76
- # this avoids reemiting back to an earlier match that
77
- # itself did a reemit to the current match that is reemitting.
88
+ # We want to reemit messages to the next `<match>` below this `type reemit`
89
+ # to avoid reemiting back to an above or current `<match>`
78
90
  pipeline = nil
79
91
  found_reemit = false
80
92
  @match_rules.each_with_index { |rule, i|
@@ -109,6 +121,16 @@ module Fluent
109
121
  end
110
122
  end
111
123
 
124
+ # Almost same as V12EventRouter but it must call #emit_events instead of #emit.
125
+ class V14EventRouter < V12EventRouter
126
+ # same
127
+ def emit_stream(tag, es)
128
+ match(tag).emit_events(tag, es)
129
+ rescue => e
130
+ @emit_error_handler.handle_emits_error(tag, es, e)
131
+ end
132
+ end
133
+
112
134
  class V10Engine
113
135
  def initialize(reemit)
114
136
  @reemit = reemit
@@ -126,9 +148,8 @@ module Fluent
126
148
  end
127
149
 
128
150
  def match(tag)
129
- # we want to reemit to the next match after this reemit
130
- # this avoids reemiting back to an earlier match that
131
- # itself did a reemit to the current match that is reemitting.
151
+ # We want to reemit messages to the next `<match>` below this `type reemit`
152
+ # to avoid reemiting back to an above or current `<match>`
132
153
  found_reemit = false
133
154
  @matches.find do |m|
134
155
  if m.match(tag)
@@ -1,10 +1,18 @@
1
1
  # encoding: UTF-8
2
2
  require_relative 'spec_helper'
3
+ require 'fluent/plugin/out_copy'
4
+ if Fluent::VERSION > '0.14'
5
+ require 'fluent/test/driver/multi_output'
6
+ end
3
7
 
4
8
  describe Fluent::ReemitOutput do
5
9
  before { Fluent::Test.setup }
6
10
  def create_driver(config, tag = 'test')
7
- Fluent::Test::OutputTestDriver.new(Fluent::CopyOutput, tag).configure(config)
11
+ if Fluent::VERSION > '0.14'
12
+ Fluent::Test::Driver::MultiOutput.new(Fluent::Plugin::CopyOutput).configure(config)
13
+ else
14
+ Fluent::Test::OutputTestDriver.new(Fluent::CopyOutput, tag).configure(config)
15
+ end
8
16
  end
9
17
 
10
18
  # THIS TEST IS ABSOLUTELY NOT ENOUGH. INSTEAD, RUN
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-reemit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-10 00:00:00.000000000 Z
11
+ date: 2017-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: test-unit
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: Fluentd plugin to re-emit messages avoiding infinity match loop
84
98
  email: sonots@gmail.com
85
99
  executables: []
@@ -91,6 +105,7 @@ files:
91
105
  - ".travis.yml"
92
106
  - CHANGELOG.md
93
107
  - Gemfile
108
+ - Gemfile.v0.10
94
109
  - Gemfile.v0.12
95
110
  - LICENSE
96
111
  - README.md
@@ -121,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
136
  version: '0'
122
137
  requirements: []
123
138
  rubyforge_project:
124
- rubygems_version: 2.2.2
139
+ rubygems_version: 2.5.1
125
140
  signing_key:
126
141
  specification_version: 4
127
142
  summary: Fluentd plugin to re-emit messages avoiding infinity match loop