fluent-plugin-redis-render 0.2.2 → 0.2.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/.gitignore +3 -0
- data/Gemfile.lock +12 -14
- data/fluent-plugin-redis-store.gemspec +3 -3
- data/lib/fluent/plugin/out_redis_store.rb +57 -58
- data/test/plugin/test_out_redis_publish.rb +10 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad7d27266ac4898fde77f36b733641955f84660b946f51c86df5e617c9ca93cd
|
4
|
+
data.tar.gz: 6ade50a10cebc63054d8908192f3c79cd27429f1db5551bc4d8080387f98fd41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d4d7e9ce6eecae1e13760b4a508e0418bc445e00e472cdc7cf7fb90c5dea7e3a0601eb3ced523d2b2663a3430b9f9b55a480105d9e3d1891c7f6d3e5229617d
|
7
|
+
data.tar.gz: 4f289bd0c1a16a6de06797069a68eb29693bb8dc783b5df3a2e385b4b24b2174b19218d0ab3e1177bf1afe44a0b7aa50989aff3f1813d5c4c5d92fa63e5d234c
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,41 +1,39 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fluent-plugin-redis-render (0.2.
|
4
|
+
fluent-plugin-redis-render (0.2.4)
|
5
5
|
fluentd (>= 0.14.15, < 2)
|
6
6
|
redis
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
10
10
|
specs:
|
11
|
-
|
12
|
-
|
13
|
-
fluentd (1.
|
11
|
+
concurrent-ruby (1.1.6)
|
12
|
+
cool.io (1.6.0)
|
13
|
+
fluentd (1.10.3)
|
14
14
|
cool.io (>= 1.4.5, < 2.0.0)
|
15
|
-
dig_rb (~> 1.0.0)
|
16
15
|
http_parser.rb (>= 0.5.1, < 0.7.0)
|
17
|
-
msgpack (>=
|
16
|
+
msgpack (>= 1.3.1, < 2.0.0)
|
18
17
|
serverengine (>= 2.0.4, < 3.0.0)
|
19
18
|
sigdump (~> 0.2.2)
|
20
19
|
strptime (>= 0.2.2, < 1.0.0)
|
21
|
-
tzinfo (
|
20
|
+
tzinfo (>= 1.0, < 3.0)
|
22
21
|
tzinfo-data (~> 1.0)
|
23
22
|
yajl-ruby (~> 1.0)
|
24
23
|
http_parser.rb (0.6.0)
|
25
|
-
msgpack (1.
|
24
|
+
msgpack (1.3.3)
|
26
25
|
power_assert (1.1.4)
|
27
26
|
rake (12.3.2)
|
28
|
-
redis (4.1.
|
29
|
-
serverengine (2.1
|
27
|
+
redis (4.1.4)
|
28
|
+
serverengine (2.2.1)
|
30
29
|
sigdump (~> 0.2.2)
|
31
30
|
sigdump (0.2.4)
|
32
31
|
strptime (0.2.3)
|
33
32
|
test-unit (3.3.2)
|
34
33
|
power_assert
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
tzinfo-data (1.2019.1)
|
34
|
+
tzinfo (2.0.2)
|
35
|
+
concurrent-ruby (~> 1.0)
|
36
|
+
tzinfo-data (1.2020.1)
|
39
37
|
tzinfo (>= 1.0.0)
|
40
38
|
yajl-ruby (1.4.1)
|
41
39
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |gem|
|
3
3
|
gem.name = "fluent-plugin-redis-render"
|
4
|
-
gem.email = "
|
5
|
-
gem.version = "0.2.
|
4
|
+
gem.email = "dev@render.com"
|
5
|
+
gem.version = "0.2.4"
|
6
6
|
gem.authors = ["moaikids", "HANAI Tohru aka pokehanai"]
|
7
7
|
gem.licenses = ["Apache License Version 2.0"]
|
8
8
|
gem.summary = %q{Redis(zset/set/list/string/publish) output plugin for Fluentd}
|
9
9
|
gem.description = %q{Redis(zset/set/list/string/publish) output plugin for Fluentd...}
|
10
|
-
gem.homepage = "https://github.com/
|
10
|
+
gem.homepage = "https://github.com/pokehanai/fluent-plugin-redis-store"
|
11
11
|
|
12
12
|
gem.files = `git ls-files`.split($\)
|
13
13
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -9,28 +9,28 @@ module Fluent::Plugin
|
|
9
9
|
DEFAULT_BUFFER_TYPE = "memory"
|
10
10
|
|
11
11
|
# redis connection
|
12
|
-
config_param :host,
|
13
|
-
config_param :port,
|
14
|
-
config_param :path,
|
15
|
-
config_param :password,
|
16
|
-
config_param :db,
|
17
|
-
config_param :timeout,
|
18
|
-
config_param :cluster_nodes, :string, :default => nil
|
12
|
+
config_param :host, :string, :default => '127.0.0.1'
|
13
|
+
config_param :port, :integer, :default => 6379
|
14
|
+
config_param :path, :string, :default => nil
|
15
|
+
config_param :password, :string, :default => nil
|
16
|
+
config_param :db, :integer, :default => 0
|
17
|
+
config_param :timeout, :float, :default => 5.0
|
19
18
|
|
20
19
|
# redis command and parameters
|
21
|
-
config_param :format_type,
|
22
|
-
config_param :store_type,
|
23
|
-
config_param :key_prefix,
|
24
|
-
config_param :key_suffix,
|
25
|
-
config_param :key,
|
26
|
-
config_param :key_path,
|
27
|
-
config_param :score_path,
|
28
|
-
config_param :value_path,
|
29
|
-
config_param :key_expire,
|
30
|
-
config_param :value_expire,
|
31
|
-
config_param :value_length,
|
32
|
-
config_param :
|
33
|
-
config_param :
|
20
|
+
config_param :format_type, :string, :default => 'json'
|
21
|
+
config_param :store_type, :string, :default => 'zset'
|
22
|
+
config_param :key_prefix, :string, :default => ''
|
23
|
+
config_param :key_suffix, :string, :default => ''
|
24
|
+
config_param :key, :string, :default => nil
|
25
|
+
config_param :key_path, :string, :default => nil
|
26
|
+
config_param :score_path, :string, :default => nil
|
27
|
+
config_param :value_path, :string, :default => ''
|
28
|
+
config_param :key_expire, :integer, :default => -1
|
29
|
+
config_param :value_expire, :integer, :default => -1
|
30
|
+
config_param :value_length, :integer, :default => -1
|
31
|
+
config_param :max_list_length, :integer, :default => 1000
|
32
|
+
config_param :order, :string, :default => 'asc'
|
33
|
+
config_param :collision_policy, :string, :default => nil
|
34
34
|
config_set_default :flush_interval, 1
|
35
35
|
|
36
36
|
config_section :buffer do
|
@@ -57,10 +57,6 @@ module Fluent::Plugin
|
|
57
57
|
if @path
|
58
58
|
@redis = Redis.new(:path => @path, :password => @password,
|
59
59
|
:timeout => @timeout, :thread_safe => true, :db => @db)
|
60
|
-
elsif @cluster_nodes
|
61
|
-
nodes = @cluster_nodes.split(' ')
|
62
|
-
@redis = Redis.new(:cluster => nodes, :password => @password,
|
63
|
-
:timeout => @timeout, :thread_safe => true, :db => @db)
|
64
60
|
else
|
65
61
|
@redis = Redis.new(:host => @host, :port => @port, :password => @password,
|
66
62
|
:timeout => @timeout, :thread_safe => true, :db => @db)
|
@@ -85,34 +81,36 @@ module Fluent::Plugin
|
|
85
81
|
end
|
86
82
|
|
87
83
|
def write(chunk)
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
84
|
+
@redis.pipelined {
|
85
|
+
chunk.open { |io|
|
86
|
+
begin
|
87
|
+
MessagePack::Unpacker.new(io).each { |message|
|
88
|
+
begin
|
89
|
+
(_, time, record) = message
|
90
|
+
case @store_type
|
91
|
+
when 'zset'
|
92
|
+
operation_for_zset(record, time)
|
93
|
+
when 'set'
|
94
|
+
operation_for_set(record)
|
95
|
+
when 'list'
|
96
|
+
operation_for_list(record)
|
97
|
+
when 'string'
|
98
|
+
operation_for_string(record)
|
99
|
+
when 'publish'
|
100
|
+
operation_for_publish(record)
|
101
|
+
end
|
102
|
+
rescue NoMethodError => e
|
103
|
+
puts e
|
104
|
+
rescue Encoding::UndefinedConversionError => e
|
105
|
+
log.error "Plugin error: " + e.to_s
|
106
|
+
log.error "Original record: " + record.to_s
|
107
|
+
puts e
|
104
108
|
end
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
puts e
|
111
|
-
end
|
112
|
-
}
|
113
|
-
rescue EOFError
|
114
|
-
# EOFError always occured when reached end of chunk.
|
115
|
-
end
|
109
|
+
}
|
110
|
+
rescue EOFError
|
111
|
+
# EOFError always occured when reached end of chunk.
|
112
|
+
end
|
113
|
+
}
|
116
114
|
}
|
117
115
|
end
|
118
116
|
|
@@ -133,7 +131,7 @@ module Fluent::Plugin
|
|
133
131
|
set_key_expire key
|
134
132
|
if 0 < @value_expire
|
135
133
|
now = Time.now.to_i
|
136
|
-
@redis.zremrangebyscore key, '-inf', (now - @value_expire)
|
134
|
+
@redis.zremrangebyscore key , '-inf' , (now - @value_expire)
|
137
135
|
end
|
138
136
|
if 0 < @value_length
|
139
137
|
script = generate_zremrangebyrank_script(key, @value_length, @order)
|
@@ -157,6 +155,9 @@ module Fluent::Plugin
|
|
157
155
|
else
|
158
156
|
@redis.lpush key, value
|
159
157
|
end
|
158
|
+
|
159
|
+
@redis.ltrim key, 0, @max_list_length - 1 if 0 < @max_list_length
|
160
|
+
|
160
161
|
set_key_expire key
|
161
162
|
if 0 < @value_length
|
162
163
|
script = generate_ltrim_script(key, @value_length, @order)
|
@@ -179,7 +180,7 @@ module Fluent::Plugin
|
|
179
180
|
end
|
180
181
|
|
181
182
|
def generate_zremrangebyrank_script(key, maxlen, order)
|
182
|
-
script
|
183
|
+
script = "local key = '" + key.to_s + "'\n"
|
183
184
|
script += "local maxlen = " + maxlen.to_s + "\n"
|
184
185
|
script += "local order ='" + order.to_s + "'\n"
|
185
186
|
script += "local len = tonumber(redis.call('ZCOUNT', key, '-inf', '+inf'))\n"
|
@@ -197,7 +198,7 @@ module Fluent::Plugin
|
|
197
198
|
end
|
198
199
|
|
199
200
|
def generate_ltrim_script(key, maxlen, order)
|
200
|
-
script
|
201
|
+
script = "local key = '" + key.to_s + "'\n"
|
201
202
|
script += "local maxlen = " + maxlen.to_s + "\n"
|
202
203
|
script += "local order ='" + order.to_s + "'\n"
|
203
204
|
script += "local len = tonumber(redis.call('LLEN', key))\n"
|
@@ -214,7 +215,7 @@ module Fluent::Plugin
|
|
214
215
|
|
215
216
|
def traverse(data, key)
|
216
217
|
val = data
|
217
|
-
key.split('.').each
|
218
|
+
key.split('.').each{ |k|
|
218
219
|
if val.has_key?(k)
|
219
220
|
val = val[k]
|
220
221
|
else
|
@@ -257,9 +258,7 @@ module Fluent::Plugin
|
|
257
258
|
end
|
258
259
|
|
259
260
|
def set_key_expire(key)
|
260
|
-
if 0 < @key_expire
|
261
|
-
@redis.expire key, @key_expire
|
262
|
-
end
|
261
|
+
@redis.expire key, @key_expire if 0 < @key_expire
|
263
262
|
end
|
264
263
|
|
265
264
|
end
|
@@ -29,6 +29,13 @@ class Redis
|
|
29
29
|
$message = message
|
30
30
|
end
|
31
31
|
|
32
|
+
def ltrim(key, start, stop)
|
33
|
+
$command = :ltrim
|
34
|
+
$key = key
|
35
|
+
$start = start
|
36
|
+
$stop = stop
|
37
|
+
end
|
38
|
+
|
32
39
|
def sadd(key, message)
|
33
40
|
$command = :sadd
|
34
41
|
$key = key
|
@@ -91,7 +98,7 @@ class RedisStoreOutputTest < Test::Unit::TestCase
|
|
91
98
|
assert_equal(-1, d.instance.value_length)
|
92
99
|
assert_equal('asc', d.instance.order)
|
93
100
|
assert_equal(nil, d.instance.collision_policy)
|
94
|
-
assert_equal(
|
101
|
+
assert_equal(1000, d.instance.max_list_length)
|
95
102
|
end
|
96
103
|
|
97
104
|
def test_configure_host_port_db
|
@@ -237,6 +244,7 @@ class RedisStoreOutputTest < Test::Unit::TestCase
|
|
237
244
|
format_type plain
|
238
245
|
store_type list
|
239
246
|
key_path user
|
247
|
+
max_list_length 0
|
240
248
|
]
|
241
249
|
d = create_driver(config)
|
242
250
|
message = {
|
@@ -268,7 +276,7 @@ class RedisStoreOutputTest < Test::Unit::TestCase
|
|
268
276
|
d.feed(get_time, message)
|
269
277
|
end
|
270
278
|
|
271
|
-
assert_equal :
|
279
|
+
assert_equal :ltrim, $command
|
272
280
|
assert_equal "george", $key
|
273
281
|
assert_equal message, $message
|
274
282
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-redis-render
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- moaikids
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-05-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -74,7 +74,7 @@ dependencies:
|
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
description: Redis(zset/set/list/string/publish) output plugin for Fluentd...
|
77
|
-
email:
|
77
|
+
email: dev@render.com
|
78
78
|
executables: []
|
79
79
|
extensions: []
|
80
80
|
extra_rdoc_files: []
|
@@ -89,7 +89,7 @@ files:
|
|
89
89
|
- lib/fluent/plugin/out_redis_store.rb
|
90
90
|
- test/helpers.rb
|
91
91
|
- test/plugin/test_out_redis_publish.rb
|
92
|
-
homepage: https://github.com/
|
92
|
+
homepage: https://github.com/pokehanai/fluent-plugin-redis-store
|
93
93
|
licenses:
|
94
94
|
- Apache License Version 2.0
|
95
95
|
metadata: {}
|