fluent-plugin-reemit 0.2.1 → 0.3.0
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 +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +6 -3
- data/CHANGELOG.md +6 -0
- data/Gemfile.v0.10 +5 -0
- data/Gemfile.v0.12 +1 -1
- data/fluent-plugin-reemit.gemspec +2 -1
- data/lib/fluent/plugin/out_reemit.rb +30 -9
- data/spec/out_reemit_spec.rb +9 -1
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4694b1e10321c8954b685c7d010244e78e7e953d
|
4
|
+
data.tar.gz: 5a1905a04b7fa654df1397cccc19671f0ded31b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5af41dc4e9b4608dedd759c8f2110797c94500b3b9487d31f4921a2b868c0f11fe24c9df54dbc36904fc902ddda4a5db9e9470da3c6803b8fc457921a326802c
|
7
|
+
data.tar.gz: 5a7de06331278710042bfb6379000ba84f2079849c7d4691473edd98ca81a50f84f01137ed9ef5244e4156fa866a940735780fddf47e05f87d12f3837e361c02
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.v0.10
ADDED
data/Gemfile.v0.12
CHANGED
@@ -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.
|
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/
|
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
|
20
|
-
|
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
|
-
#
|
76
|
-
#
|
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
|
-
#
|
130
|
-
#
|
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)
|
data/spec/out_reemit_spec.rb
CHANGED
@@ -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::
|
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.
|
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:
|
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.
|
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
|