fluent-plugin-kafka 0.6.3 → 0.6.4
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 +5 -5
- data/ChangeLog +7 -0
- data/LICENSE +10 -18
- data/fluent-plugin-kafka.gemspec +3 -2
- data/lib/fluent/plugin/in_kafka.rb +24 -7
- data/lib/fluent/plugin/in_kafka_group.rb +18 -3
- data/lib/fluent/plugin/out_kafka.rb +4 -0
- data/lib/fluent/plugin/out_kafka_buffered.rb +12 -2
- data/test/plugin/test_out_kafka.rb +6 -0
- metadata +13 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: efe26ba34b8d77d120aa8c7babfaa69360520698079dee0be5caefb388964e4a
|
4
|
+
data.tar.gz: 0c42b0e54db31526150f1e0f71ee94a7c336112c649e0f39d77a4104f7202268
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95baf194bcc5a486cf1c924500468f49f31a6c9f55ce39f811f37b221017f75956002110c260ab1577f8d701b4f917364ce6042d9507a105254ca3c013395ca8
|
7
|
+
data.tar.gz: 8de6a01fd63e12c6f34ab91522db088b6fd25fc6d1b2d924d3b1e69c4fb11f7e773ae07a0be6790a7bfcb7e5c6f060594ab4b1c84c5eb4f856a40b52a3c6cf02
|
data/ChangeLog
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
Release 0.6.4 - 2017/11/23
|
2
|
+
|
3
|
+
* Multi worker support for v0.14
|
4
|
+
* Add kafka_message_key parameter to input plugins
|
5
|
+
* Relax ruby-kafka version for 0.5 or later
|
6
|
+
* Use oj for json when it is installed
|
7
|
+
|
1
8
|
Release 0.6.3 - 2017/11/14
|
2
9
|
|
3
10
|
* in_kafka_group: re-create consumer when error happens during event fetch
|
data/LICENSE
CHANGED
@@ -1,22 +1,14 @@
|
|
1
|
-
Copyright (
|
1
|
+
Copyright (C) 2014 htgc
|
2
2
|
|
3
|
-
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
4
6
|
|
5
|
-
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
12
8
|
|
13
|
-
|
14
|
-
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
15
14
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/fluent-plugin-kafka.gemspec
CHANGED
@@ -6,18 +6,19 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.description = %q{Fluentd plugin for Apache Kafka > 0.8}
|
7
7
|
gem.summary = %q{Fluentd plugin for Apache Kafka > 0.8}
|
8
8
|
gem.homepage = "https://github.com/fluent/fluent-plugin-kafka"
|
9
|
+
gem.license = "Apache-2.0"
|
9
10
|
|
10
11
|
gem.files = `git ls-files`.split($\)
|
11
12
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
12
13
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
14
|
gem.name = "fluent-plugin-kafka"
|
14
15
|
gem.require_paths = ["lib"]
|
15
|
-
gem.version = '0.6.
|
16
|
+
gem.version = '0.6.4'
|
16
17
|
gem.required_ruby_version = ">= 2.1.0"
|
17
18
|
|
18
19
|
gem.add_dependency "fluentd", [">= 0.10.58", "< 2"]
|
19
20
|
gem.add_dependency 'ltsv'
|
20
|
-
gem.add_dependency 'ruby-kafka', '
|
21
|
+
gem.add_dependency 'ruby-kafka', '>= 0.4.1', '< 1.0.0'
|
21
22
|
gem.add_development_dependency "rake", ">= 0.9.2"
|
22
23
|
gem.add_development_dependency "test-unit", ">= 3.0.8"
|
23
24
|
end
|
@@ -36,6 +36,8 @@ class Fluent::KafkaInput < Fluent::Input
|
|
36
36
|
:desc => "Replace message timestamp with contents of 'time' field."
|
37
37
|
config_param :time_format, :string, :default => nil,
|
38
38
|
:desc => "Time format to be used to parse 'time' filed."
|
39
|
+
config_param :kafka_message_key, :string, :default => nil,
|
40
|
+
:desc => "Set kafka's message key to this field"
|
39
41
|
|
40
42
|
# Kafka#fetch_messages options
|
41
43
|
config_param :max_bytes, :integer, :default => nil,
|
@@ -113,12 +115,22 @@ class Fluent::KafkaInput < Fluent::Input
|
|
113
115
|
def setup_parser
|
114
116
|
case @format
|
115
117
|
when 'json'
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
118
|
+
begin
|
119
|
+
require 'oj'
|
120
|
+
Oj.default_options = Fluent::DEFAULT_OJ_OPTIONS
|
121
|
+
Proc.new { |msg, te|
|
122
|
+
r = Oj.load(msg.value)
|
123
|
+
add_offset_in_hash(r, te, msg.offset) if @add_offset_in_record
|
124
|
+
r
|
125
|
+
}
|
126
|
+
rescue LoadError
|
127
|
+
require 'yajl'
|
128
|
+
Proc.new { |msg, te|
|
129
|
+
r = Yajl::Parser.parse(msg.value)
|
130
|
+
add_offset_in_hash(r, te, msg.offset) if @add_offset_in_record
|
131
|
+
r
|
132
|
+
}
|
133
|
+
end
|
122
134
|
when 'ltsv'
|
123
135
|
require 'ltsv'
|
124
136
|
Proc.new { |msg, te|
|
@@ -175,6 +187,7 @@ class Fluent::KafkaInput < Fluent::Input
|
|
175
187
|
@add_suffix,
|
176
188
|
offset_manager,
|
177
189
|
router,
|
190
|
+
@kafka_message_key,
|
178
191
|
opt)
|
179
192
|
}
|
180
193
|
@topic_watchers.each {|tw|
|
@@ -199,7 +212,7 @@ class Fluent::KafkaInput < Fluent::Input
|
|
199
212
|
end
|
200
213
|
|
201
214
|
class TopicWatcher < Coolio::TimerWatcher
|
202
|
-
def initialize(topic_entry, kafka, interval, parser, add_prefix, add_suffix, offset_manager, router, options={})
|
215
|
+
def initialize(topic_entry, kafka, interval, parser, add_prefix, add_suffix, offset_manager, router, kafka_message_key, options={})
|
203
216
|
@topic_entry = topic_entry
|
204
217
|
@kafka = kafka
|
205
218
|
@callback = method(:consume)
|
@@ -209,6 +222,7 @@ class Fluent::KafkaInput < Fluent::Input
|
|
209
222
|
@options = options
|
210
223
|
@offset_manager = offset_manager
|
211
224
|
@router = router
|
225
|
+
@kafka_message_key = kafka_message_key
|
212
226
|
|
213
227
|
@next_offset = @topic_entry.offset
|
214
228
|
if @topic_entry.offset == -1 && offset_manager
|
@@ -254,6 +268,9 @@ class Fluent::KafkaInput < Fluent::Input
|
|
254
268
|
else
|
255
269
|
record_time = Fluent::Engine.now
|
256
270
|
end
|
271
|
+
if @kafka_message_key
|
272
|
+
record[@kafka_message_key] = msg.key
|
273
|
+
end
|
257
274
|
es.add(record_time, record)
|
258
275
|
rescue => e
|
259
276
|
$log.warn "parser error in #{@topic_entry.topic}/#{@topic_entry.partition}", :error => e.to_s, :value => msg.value, :offset => msg.offset
|
@@ -25,6 +25,8 @@ class Fluent::KafkaGroupInput < Fluent::Input
|
|
25
25
|
:desc => "Replace message timestamp with contents of 'time' field."
|
26
26
|
config_param :time_format, :string, :default => nil,
|
27
27
|
:desc => "Time format to be used to parse 'time' filed."
|
28
|
+
config_param :kafka_message_key, :string, :default => nil,
|
29
|
+
:desc => "Set kafka's message key to this field"
|
28
30
|
|
29
31
|
config_param :retry_wait_seconds, :integer, :default => 30
|
30
32
|
# Kafka consumer options
|
@@ -74,6 +76,10 @@ class Fluent::KafkaGroupInput < Fluent::Input
|
|
74
76
|
config_array
|
75
77
|
end
|
76
78
|
|
79
|
+
def multi_workers_ready?
|
80
|
+
true
|
81
|
+
end
|
82
|
+
|
77
83
|
private :_config_to_array
|
78
84
|
|
79
85
|
def configure(conf)
|
@@ -108,8 +114,14 @@ class Fluent::KafkaGroupInput < Fluent::Input
|
|
108
114
|
def setup_parser
|
109
115
|
case @format
|
110
116
|
when 'json'
|
111
|
-
|
112
|
-
|
117
|
+
begin
|
118
|
+
require 'oj'
|
119
|
+
Oj.default_options = Fluent::DEFAULT_OJ_OPTIONS
|
120
|
+
Proc.new { |msg| Oj.load(msg.value) }
|
121
|
+
rescue LoadError
|
122
|
+
require 'yajl'
|
123
|
+
Proc.new { |msg| Yajl::Parser.parse(msg.value) }
|
124
|
+
end
|
113
125
|
when 'ltsv'
|
114
126
|
require 'ltsv'
|
115
127
|
Proc.new { |msg| LTSV.parse(msg.value, {:symbolize_keys => false}).first }
|
@@ -123,7 +135,7 @@ class Fluent::KafkaGroupInput < Fluent::Input
|
|
123
135
|
|
124
136
|
def start
|
125
137
|
super
|
126
|
-
|
138
|
+
|
127
139
|
@kafka = Kafka.new(seed_brokers: @brokers,
|
128
140
|
ssl_ca_cert: read_ssl_file(@ssl_ca_cert),
|
129
141
|
ssl_client_cert: read_ssl_file(@ssl_client_cert),
|
@@ -189,6 +201,9 @@ class Fluent::KafkaGroupInput < Fluent::Input
|
|
189
201
|
else
|
190
202
|
record_time = Fluent::Engine.now
|
191
203
|
end
|
204
|
+
if @kafka_message_key
|
205
|
+
record[@kafka_message_key] = msg.key
|
206
|
+
end
|
192
207
|
es.add(record_time, record)
|
193
208
|
rescue => e
|
194
209
|
log.warn "parser error in #{batch.topic}/#{batch.partition}", :error => e.to_s, :value => msg.value, :offset => msg.offset
|
@@ -98,6 +98,10 @@ DESC
|
|
98
98
|
@producers_mutex = Mutex.new
|
99
99
|
end
|
100
100
|
|
101
|
+
def multi_workers_ready?
|
102
|
+
true
|
103
|
+
end
|
104
|
+
|
101
105
|
def refresh_client(raise_error = true)
|
102
106
|
if @zookeeper
|
103
107
|
@seed_brokers = []
|
@@ -218,8 +222,14 @@ DESC
|
|
218
222
|
|
219
223
|
def setup_formatter(conf)
|
220
224
|
if @output_data_type == 'json'
|
221
|
-
|
222
|
-
|
225
|
+
begin
|
226
|
+
require 'oj'
|
227
|
+
Oj.default_options = Fluent::DEFAULT_OJ_OPTIONS
|
228
|
+
Proc.new { |tag, time, record| Oj.dump(record) }
|
229
|
+
rescue LoadError
|
230
|
+
require 'yajl'
|
231
|
+
Proc.new { |tag, time, record| Yajl::Encoder.encode(record) }
|
232
|
+
end
|
223
233
|
elsif @output_data_type == 'ltsv'
|
224
234
|
require 'ltsv'
|
225
235
|
Proc.new { |tag, time, record| LTSV.dump(record) }
|
@@ -43,6 +43,12 @@ class KafkaOutputTest < Test::Unit::TestCase
|
|
43
43
|
d = create_driver
|
44
44
|
end
|
45
45
|
|
46
|
+
def test_mutli_worker_support
|
47
|
+
d = create_driver
|
48
|
+
assert_equal true, d.instance.multi_workers_ready?
|
49
|
+
|
50
|
+
end
|
51
|
+
|
46
52
|
def test_write
|
47
53
|
d = create_driver
|
48
54
|
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-kafka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hidemasa Togashi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-11-
|
12
|
+
date: 2017-11-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|
@@ -49,16 +49,22 @@ dependencies:
|
|
49
49
|
name: ruby-kafka
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.4.1
|
55
|
+
- - "<"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 1.0.0
|
55
58
|
type: :runtime
|
56
59
|
prerelease: false
|
57
60
|
version_requirements: !ruby/object:Gem::Requirement
|
58
61
|
requirements:
|
59
|
-
- - "
|
62
|
+
- - ">="
|
60
63
|
- !ruby/object:Gem::Version
|
61
64
|
version: 0.4.1
|
65
|
+
- - "<"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 1.0.0
|
62
68
|
- !ruby/object:Gem::Dependency
|
63
69
|
name: rake
|
64
70
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,7 +119,8 @@ files:
|
|
113
119
|
- test/helper.rb
|
114
120
|
- test/plugin/test_out_kafka.rb
|
115
121
|
homepage: https://github.com/fluent/fluent-plugin-kafka
|
116
|
-
licenses:
|
122
|
+
licenses:
|
123
|
+
- Apache-2.0
|
117
124
|
metadata: {}
|
118
125
|
post_install_message:
|
119
126
|
rdoc_options: []
|
@@ -131,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
138
|
version: '0'
|
132
139
|
requirements: []
|
133
140
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.
|
141
|
+
rubygems_version: 2.7.2
|
135
142
|
signing_key:
|
136
143
|
specification_version: 4
|
137
144
|
summary: Fluentd plugin for Apache Kafka > 0.8
|