fluent-plugin-reemit 0.0.3 → 0.0.4

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: 28e555df53cba5c36b2e18a3ac61c83bdf1b1ede
4
- data.tar.gz: 9f2ee252b827c5d47131bd7a5b78fa83d6dca1d7
3
+ metadata.gz: e813b632ab6a8e9d25674b0797d86e164c0f0dcf
4
+ data.tar.gz: d9bd28e6b7d18eed818154cf8a6e0305ee662b03
5
5
  SHA512:
6
- metadata.gz: b586019a20b552fdef247349ffcd6447c647c3dbbd3cb5f0268845efa8ad4f9aa380a43dcc1e5c0af9cbec0dfb253f92d9a633b321c717553eab9a5118e84127
7
- data.tar.gz: f0d0a817bc8d0d49ca071f9d9f89164f1ffde2e010c7b3f06a1ca2615e2d2618601926218c53cb0c741391bfc4f7740ef38e97ddc11ac5de0f5df170efe0a977
6
+ metadata.gz: 2e54b924c5b92305d5a3ef091dd9b479b34612c2451f3da471957e87f346e64df976ed2370fd64216681c8a6beb9e1e77887796451b09bea3edc84129c357726
7
+ data.tar.gz: 34e643e7411db05b9af1b2f3b1c98d8c35ac14d60f6de187949bbfdcf53e48a5b9e3a253a7cb7b122294bbe489d348c224c1dfaa7b5f30d5cd10c91aaba41be6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.0.4 (2014/04/04)
2
+
3
+ Enhancement:
4
+
5
+ * Support recursive MultiOutput
6
+
1
7
  ## 0.0.3 (2014/02/04)
2
8
 
3
9
  Enhancement:
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
4
  gem 'fluent-plugin-flowcounter' # for examples
5
+ gem 'pry'
6
+ gem 'pry-nav'
@@ -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.0.3"
6
+ gem.version = "0.0.4"
7
7
  gem.authors = ["Naotoshi Seo"]
8
8
  gem.email = "sonots@gmail.com"
9
9
  gem.homepage = "https://github.com/sonots/fluent-plugin-reemit"
@@ -23,8 +23,6 @@ module Fluent
23
23
  log.warn "reemit: #{e.class} #{e.message} #{e.backtrace.first}"
24
24
  end
25
25
 
26
- private
27
-
28
26
  # My Engine.emit
29
27
  def engine_emit(tag, es)
30
28
  target = @match_cache[tag]
@@ -38,11 +36,9 @@ module Fluent
38
36
  # My Engine.match
39
37
  def engine_match(tag)
40
38
  # @matches.find {|m| m.match(tag) } # original Engine.match
41
- Engine.matches.find {|m| ignore_self_match(m, tag) }
39
+ Engine.matches.find {|m| match_without_self(m, tag) }
42
40
  end
43
41
 
44
- # Currently support only
45
- #
46
42
  # <match foo.bar>
47
43
  # type reemit
48
44
  # </match>
@@ -55,10 +51,20 @@ module Fluent
55
51
  # type reemit
56
52
  # </store>
57
53
  # </match>
58
- def ignore_self_match(m, tag)
59
- return false if m.output == self
60
- return false if m.output.kind_of?(MultiOutput) and m.output.outputs.include?(self)
54
+ def match_without_self(m, tag)
55
+ return false if contain_self?(m.output)
61
56
  m.match(tag)
62
57
  end
58
+
59
+ def contain_self?(output)
60
+ if output.kind_of?(MultiOutput)
61
+ output.outputs.each do |o|
62
+ return true if contain_self?(o)
63
+ end
64
+ else
65
+ return true if output == self
66
+ end
67
+ false
68
+ end
63
69
  end
64
70
  end
@@ -3,5 +3,62 @@ require_relative 'spec_helper'
3
3
 
4
4
  describe Fluent::ReemitOutput do
5
5
  before { Fluent::Test.setup }
6
- # There is not test driver which suites
6
+ def create_driver(config, tag = 'test')
7
+ Fluent::Test::OutputTestDriver.new(Fluent::CopyOutput, tag).configure(config)
8
+ end
9
+
10
+ describe '#contain_self?' do
11
+ it 'should contain self' do
12
+ config = %[
13
+ <store>
14
+ type reemit
15
+ </store>
16
+ <store>
17
+ type stdout
18
+ </store>
19
+ ]
20
+ output = create_driver(config).instance
21
+ reemit = output.outputs.first
22
+ reemit.contain_self?(output).should be_true
23
+ end
24
+
25
+ it 'should not contain self' do
26
+ reemit_config = %[
27
+ <store>
28
+ type reemit
29
+ </store>
30
+ <store>
31
+ type stdout
32
+ </store>
33
+ ]
34
+ noreemit_config = %[
35
+ <store>
36
+ type stdout
37
+ </store>
38
+ ]
39
+ reemit = create_driver(reemit_config).instance.outputs.first
40
+ output = create_driver(noreemit_config).instance
41
+ reemit.contain_self?(output).should be_false
42
+ end
43
+
44
+ it 'should contain self in deep' do
45
+ config = %[
46
+ <store>
47
+ type stdout
48
+ </store>
49
+ <store>
50
+ type copy
51
+ <store>
52
+ type stdout
53
+ </store>
54
+ <store>
55
+ type reemit
56
+ </store>
57
+ </store>
58
+ ]
59
+ output = create_driver(config).instance
60
+ reemit = output.outputs[1].outputs[1]
61
+ reemit.contain_self?(output).should be_true
62
+ end
63
+ end
7
64
  end
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.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-04 00:00:00.000000000 Z
11
+ date: 2014-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd