fluent-plugin-copy_ex 0.0.2 → 0.0.3

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: 9e5b1573225969efe890856a4a5ab0ecf3e43f4c
4
- data.tar.gz: 1f38b29b10d99a69f8d2c30b062d69f06272af84
3
+ metadata.gz: 0d312162cb51f1344bd45c89909d6188ff8d2acd
4
+ data.tar.gz: 7790f7b58b7a0367a25af1afcea4c9e0ea836989
5
5
  SHA512:
6
- metadata.gz: 2a2828d7951cda1be2e5ed3952220c46cb670145c76efeacb0607209810259e823e0fa97dda372c9c4a1acacf2e95daeaf5b420d0fc6f3bb7c09ff02afc90df4
7
- data.tar.gz: 4717f80509070ccb6f177eb0eb532bc1c9c1900d07c2989f6030903dbfbcc205fe30423d64fb58e8a92d72b31f62a860db8ec673cf67309cc8eb2c26abcecaad
6
+ metadata.gz: 06f889b19eb0c0f38af2e907ce39c5f7f1af4172a831ff0cae885e833286f8212401db19f6cd0d9f570aa81453508efac2bd08309ed5d177e27928cea76a4699
7
+ data.tar.gz: 8d7eaea66f06c7abdab6c750a2eb6e23b12564c33228672d59d21767f97733a839e931bfb536722725ef228b1a7c36eba23624c6dbd514be8ef8a06138abfebe
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.0.3 (2017-02-06)
2
+
3
+ * Support v0.14
4
+
1
5
  ## 0.0.2 (2016-09-08)
2
6
 
3
7
  * Support `@type`
data/Rakefile CHANGED
@@ -6,6 +6,7 @@ Rake::TestTask.new(:test) do |test|
6
6
  test.libs << 'lib' << 'test'
7
7
  test.pattern = 'test/**/*.rb'
8
8
  test.verbose = true
9
+ test.warning = false
9
10
  end
10
11
  task :default => :test
11
12
 
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "fluent-plugin-copy_ex"
6
- s.version = "0.0.2"
6
+ s.version = "0.0.3"
7
7
  s.authors = ["Naotoshi Seo"]
8
8
  s.email = ["sonots@gmail.com"]
9
9
  s.homepage = "https://github.com/sonots/fluent-plugin-copy_ex"
@@ -10,6 +10,7 @@ module Fluent
10
10
  super
11
11
  @outputs = []
12
12
  @ignore_errors = []
13
+ @emit_procs = []
13
14
  end
14
15
 
15
16
  attr_reader :outputs, :ignore_errors
@@ -27,6 +28,12 @@ module Fluent
27
28
 
28
29
  output = Plugin.new_output(type)
29
30
  output.configure(e)
31
+ emit_proc = if output.respond_to?(:emit_events)
32
+ Proc.new {|output, tag, es, _chain| output.emit_events(tag, es)}
33
+ else
34
+ Proc.new {|output, tag, es, _chain| output.emit(tag, es, NullOutputChain.instance)}
35
+ end
36
+ @emit_procs << emit_proc
30
37
  @outputs << output
31
38
 
32
39
  @ignore_errors << (e.arg == "ignore_error")
@@ -58,7 +65,7 @@ module Fluent
58
65
  @outputs.each_index do |idx|
59
66
  _es = @deep_copy ? es.dup : es
60
67
  begin
61
- @outputs[idx].emit(tag, _es, NullOutputChain.instance)
68
+ @emit_procs[idx].call(@outputs[idx], tag, _es, NullOutputChain.instance)
62
69
  rescue => e
63
70
  if @ignore_errors[idx]
64
71
  log.error :error_class => e.class, :error => e.message
@@ -17,6 +17,10 @@ class CopyExOutputTest < Test::Unit::TestCase
17
17
  Fluent::Test.setup
18
18
  end
19
19
 
20
+ def config_element(name = 'test', argument = '', params = {}, elements = [])
21
+ Fluent::Config::Element.new(name, argument, params, elements)
22
+ end
23
+
20
24
  CONFIG = %[
21
25
  <store>
22
26
  type test
@@ -56,9 +60,9 @@ class CopyExOutputTest < Test::Unit::TestCase
56
60
 
57
61
  outputs = d.instance.outputs
58
62
  assert_equal 3, outputs.size
59
- assert_equal Fluent::TestOutput, outputs[0].class
60
- assert_equal Fluent::TestOutput, outputs[1].class
61
- assert_equal Fluent::TestOutput, outputs[2].class
63
+ assert_equal Fluent::Plugin::TestOutput, outputs[0].class
64
+ assert_equal Fluent::Plugin::TestOutput, outputs[1].class
65
+ assert_equal Fluent::Plugin::TestOutput, outputs[2].class
62
66
  assert_equal "c0", outputs[0].name
63
67
  assert_equal "c1", outputs[1].name
64
68
  assert_equal "c2", outputs[2].name
@@ -93,18 +97,26 @@ class CopyExOutputTest < Test::Unit::TestCase
93
97
  def test_msgpack_es_emit_bug
94
98
  d = Fluent::Test::OutputTestDriver.new(Fluent::CopyExOutput)
95
99
 
100
+ emit_procs = []
96
101
  outputs = %w(p1 p2).map do |pname|
97
102
  p = Fluent::Plugin.new_output('test')
98
- p.configure('name' => pname)
103
+ p.configure(config_element('ROOT', '', {'name' => pname}))
99
104
  p.define_singleton_method(:emit) do |tag, es, chain|
100
105
  es.each do |time, record|
101
106
  super(tag, [[time, record]], chain)
102
107
  end
103
108
  end
109
+ emit_proc = if p.respond_to?(:emit_events)
110
+ Proc.new {|p, tag, es, _chain| p.emit_events(tag, es)}
111
+ else
112
+ Proc.new {|p, tag, es, _chain| p.emit(tag, es, NullOutputChain.instance)}
113
+ end
114
+ emit_procs << emit_proc
104
115
  p
105
116
  end
106
117
 
107
118
  d.instance.instance_eval { @outputs = outputs }
119
+ d.instance.instance_eval { @emit_procs = emit_procs }
108
120
 
109
121
  es = if defined?(MessagePack::Packer)
110
122
  time = Time.parse("2013-05-26 06:37:22 UTC").to_i
@@ -133,27 +145,39 @@ deep_copy true
133
145
  ]
134
146
 
135
147
  output1 = Fluent::Plugin.new_output('test')
136
- output1.configure('name' => 'output1')
137
- output1.define_singleton_method(:emit) do |tag, es, chain|
148
+ output1.configure(config_element('ROOT', '', {'name' => 'output1'}))
149
+ output1.define_singleton_method(:emit_events) do |tag, es|
138
150
  es.each do |time, record|
139
151
  record['foo'] = 'bar'
140
- super(tag, [[time, record]], chain)
152
+ super(tag, [[time, record]])
141
153
  end
142
154
  end
155
+ proc1 = if output1.respond_to?(:emit_events)
156
+ Proc.new {|output1, tag, es, _chain| output1.emit_events(tag, es)}
157
+ else
158
+ Proc.new {|output1, tag, es, _chain| output1.emit(tag, es, NullOutputChain.instance)}
159
+ end
143
160
 
144
161
  output2 = Fluent::Plugin.new_output('test')
145
- output2.configure('name' => 'output2')
146
- output2.define_singleton_method(:emit) do |tag, es, chain|
162
+ output2.configure(config_element('ROOT', '', {'name' => 'output2'}))
163
+ output2.define_singleton_method(:emit_events) do |tag, es|
147
164
  es.each do |time, record|
148
- super(tag, [[time, record]], chain)
165
+ super(tag, [[time, record]])
149
166
  end
150
167
  end
168
+ proc2 = if output2.respond_to?(:emit_events)
169
+ Proc.new {|output2, tag, es, _chain| output2.emit_events(tag, es)}
170
+ else
171
+ Proc.new {|output2, tag, es, _chain| output2.emit(tag, es, NullOutputChain.instance)}
172
+ end
151
173
 
152
174
  outputs = [output1, output2]
175
+ emit_procs = [proc1, proc2]
153
176
 
154
177
  d = Fluent::Test::OutputTestDriver.new(Fluent::CopyExOutput)
155
178
  d = d.configure(deep_copy_config) if is_deep_copy
156
179
  d.instance.instance_eval { @outputs = outputs }
180
+ d.instance.instance_eval { @emit_procs = emit_procs }
157
181
  d
158
182
  end
159
183
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-copy_ex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-08 00:00:00.000000000 Z
11
+ date: 2017-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  requirements: []
121
121
  rubyforge_project: fluent-plugin-copy_ex
122
- rubygems_version: 2.5.1
122
+ rubygems_version: 2.5.2
123
123
  signing_key:
124
124
  specification_version: 4
125
125
  summary: Fluentd out_copy extension