fluent-plugin-kinesis 0.3.3 → 0.3.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +5 -0
- data/lib/fluent/plugin/out_kinesis.rb +6 -2
- data/lib/fluent/plugin/version.rb +1 -1
- data/test/plugin/test_out_kinesis.rb +41 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1afe44290b2075c66e362e31b6ad9239b8b8a4f1
|
4
|
+
data.tar.gz: 8317862b2882294c24efd9d1e1d3434e37a82ba6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3ed7132f9ab1022c75de1eef2732858adf4cacfeb607b4a7543e3989ce6541d14b601521062eedd966bd49f52a3f8d5812505e1fedcae6fd098c29ec863f35e
|
7
|
+
data.tar.gz: 890a373bdb0c9752026fc52120b444b7eb84dbf3abc116ea4d8d78816cb0dcf8f5f35c83ca888ab295dc251a4599e1d2f9681f7ee892c0ccf93be761409a893c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -186,6 +186,11 @@ may fail for reasons documented in the Kinesis Service API Reference for PutReco
|
|
186
186
|
Failed records will be retried **retries_on_putrecords** times. If a record
|
187
187
|
fails all retries an error log will be emitted.
|
188
188
|
|
189
|
+
### use_yajl
|
190
|
+
|
191
|
+
Boolean, default is false.
|
192
|
+
In case you find error `Encoding::UndefinedConversionError` with multibyte texts, you can avoid that error with this option.
|
193
|
+
|
189
194
|
### debug
|
190
195
|
|
191
196
|
Boolean. Enable if you need to debug Amazon Kinesis API call. Default is false.
|
@@ -13,6 +13,7 @@
|
|
13
13
|
|
14
14
|
require 'aws-sdk-core'
|
15
15
|
require 'multi_json'
|
16
|
+
require 'yajl'
|
16
17
|
require 'logger'
|
17
18
|
require 'securerandom'
|
18
19
|
require 'fluent/plugin/version'
|
@@ -49,6 +50,7 @@ module FluentPluginKinesis
|
|
49
50
|
config_param :explicit_hash_key_expr, :string, default: nil
|
50
51
|
config_param :order_events, :bool, default: false
|
51
52
|
config_param :retries_on_putrecords, :integer, default: 3
|
53
|
+
config_param :use_yajl, :bool, default: false
|
52
54
|
|
53
55
|
config_param :debug, :bool, default: false
|
54
56
|
|
@@ -87,6 +89,8 @@ module FluentPluginKinesis
|
|
87
89
|
)
|
88
90
|
@explicit_hash_key_proc = eval(explicit_hash_key_proc_str)
|
89
91
|
end
|
92
|
+
|
93
|
+
@dump_class = @use_yajl ? Yajl : JSON
|
90
94
|
end
|
91
95
|
|
92
96
|
def start
|
@@ -99,7 +103,7 @@ module FluentPluginKinesis
|
|
99
103
|
|
100
104
|
def format(tag, time, record)
|
101
105
|
data = {
|
102
|
-
data: record
|
106
|
+
data: @dump_class.dump(record),
|
103
107
|
partition_key: get_key(:partition_key,record)
|
104
108
|
}
|
105
109
|
|
@@ -261,7 +265,7 @@ module FluentPluginKinesis
|
|
261
265
|
log.error sprintf(
|
262
266
|
'Could not put record, Error: %s, Record: %s',
|
263
267
|
record[:error_code],
|
264
|
-
record[:body]
|
268
|
+
@dump_class.dump(record[:body])
|
265
269
|
)
|
266
270
|
}
|
267
271
|
end
|
@@ -26,6 +26,10 @@ class KinesisOutputTest < Test::Unit::TestCase
|
|
26
26
|
partition_key test_partition_key
|
27
27
|
]
|
28
28
|
|
29
|
+
CONFIG_YAJL= CONFIG + %[
|
30
|
+
use_yajl true
|
31
|
+
]
|
32
|
+
|
29
33
|
def create_driver(conf = CONFIG, tag='test')
|
30
34
|
Fluent::Test::BufferedOutputTestDriver
|
31
35
|
.new(FluentPluginKinesis::OutputFilter, tag).configure(conf)
|
@@ -57,6 +61,7 @@ class KinesisOutputTest < Test::Unit::TestCase
|
|
57
61
|
explicit_hash_key test_hash_key
|
58
62
|
explicit_hash_key_expr record
|
59
63
|
order_events true
|
64
|
+
use_yajl true
|
60
65
|
]
|
61
66
|
d = create_driver(conf)
|
62
67
|
assert_equal 'test_stream', d.instance.stream_name
|
@@ -74,6 +79,7 @@ class KinesisOutputTest < Test::Unit::TestCase
|
|
74
79
|
d.instance.instance_variable_get(:@explicit_hash_key_proc).call('a')
|
75
80
|
assert_equal true, d.instance.order_events
|
76
81
|
assert_equal nil, d.instance.instance_variable_get(:@sequence_number_for_ordering)
|
82
|
+
assert_equal true, d.instance.use_yajl
|
77
83
|
end
|
78
84
|
|
79
85
|
def test_mode_configuration
|
@@ -141,9 +147,11 @@ class KinesisOutputTest < Test::Unit::TestCase
|
|
141
147
|
|
142
148
|
end
|
143
149
|
|
144
|
-
def test_format
|
145
150
|
|
146
|
-
|
151
|
+
data("json"=>CONFIG, "yajl"=>CONFIG_YAJL)
|
152
|
+
def test_format(config)
|
153
|
+
|
154
|
+
d = create_driver(config)
|
147
155
|
|
148
156
|
data1 = {"test_partition_key"=>"key1","a"=>1,"time"=>"2011-01-02T13:14:15Z","tag"=>"test"}
|
149
157
|
data2 = {"test_partition_key"=>"key2","a"=>2,"time"=>"2011-01-02T13:14:15Z","tag"=>"test"}
|
@@ -253,6 +261,37 @@ class KinesisOutputTest < Test::Unit::TestCase
|
|
253
261
|
)
|
254
262
|
end
|
255
263
|
|
264
|
+
def test_multibyte_with_yajl
|
265
|
+
|
266
|
+
d = create_driver(CONFIG_YAJL)
|
267
|
+
|
268
|
+
data1 = {"test_partition_key"=>"key1","a"=>"\xE3\x82\xA4\xE3\x83\xB3\xE3\x82\xB9\xE3\x83\x88\xE3\x83\xBC\xE3\x83\xAB","time"=>"2011-01-02T13:14:15Z","tag"=>"test"}
|
269
|
+
json = Yajl.dump(data1)
|
270
|
+
data1["a"].force_encoding("ASCII-8BIT")
|
271
|
+
|
272
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
273
|
+
d.emit(data1, time)
|
274
|
+
|
275
|
+
d.expect_format({
|
276
|
+
'data' => json,
|
277
|
+
'partition_key' => 'key1' }.to_msgpack
|
278
|
+
)
|
279
|
+
|
280
|
+
client = create_mock_client
|
281
|
+
client.describe_stream(stream_name: 'test_stream')
|
282
|
+
client.put_records(
|
283
|
+
stream_name: 'test_stream',
|
284
|
+
records: [
|
285
|
+
{
|
286
|
+
data: json,
|
287
|
+
partition_key: 'key1'
|
288
|
+
}
|
289
|
+
]
|
290
|
+
) { {} }
|
291
|
+
|
292
|
+
d.run
|
293
|
+
end
|
294
|
+
|
256
295
|
def test_get_key
|
257
296
|
d = create_driver
|
258
297
|
assert_equal(
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-kinesis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Amazon Web Services
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06
|
11
|
+
date: 2015-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|