fluent-plugin-redis 0.3.0 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE.md +19 -0
- data/.github/workflows/linux.yml +31 -0
- data/CHANGELOG.md +17 -1
- data/{README.rdoc → README.md} +31 -16
- data/VERSION +1 -1
- data/fluent-plugin-redis.gemspec +6 -5
- data/lib/fluent/plugin/out_redis.rb +26 -16
- data/test/plugin/test_out_redis.rb +20 -2
- metadata +29 -15
- data/.travis.yml +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f4d9ddd2edc9aeb9d4c68c945677d964ee4c25bbfc308ec658b1098186adb175
|
4
|
+
data.tar.gz: 9a39e25338b0036b237bb08e5cfc033984bd1fc33d7ba39661e44a2b692a9ee2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c66ca67dd12946c06f1a23479522a65ac5eef9f0b8b0b162380eb8eb5f12f19fe4dec0a209b0154ce73226e293ee1c089d32801adef8d72cd1dfd9daa9dcd94e
|
7
|
+
data.tar.gz: 159d112866122d37e233b37baa1aaea78371c350494ec816454e574c38f0701e1e0f797fd4a1eb288584f2826aab613bed41b6646d9d5ffa589f9a2a9286d8a0
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#### Problem
|
2
|
+
|
3
|
+
...
|
4
|
+
|
5
|
+
#### Steps to replicate
|
6
|
+
|
7
|
+
Provide example config and message
|
8
|
+
|
9
|
+
#### Expected Behavior
|
10
|
+
|
11
|
+
...
|
12
|
+
|
13
|
+
#### Your environment
|
14
|
+
|
15
|
+
* OS version
|
16
|
+
* paste result of ``fluentd --version`` or ``td-agent --version``
|
17
|
+
* plugin version
|
18
|
+
* paste boot log of fluentd or td-agent
|
19
|
+
* paste result of ``fluent-gem list``, ``td-agent-gem list`` or your Gemfile.lock
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: Testing on Ubuntu
|
2
|
+
on:
|
3
|
+
- push
|
4
|
+
- pull_request
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ${{ matrix.os }}
|
8
|
+
services:
|
9
|
+
redis:
|
10
|
+
image: redis
|
11
|
+
ports:
|
12
|
+
- 6379:6379
|
13
|
+
strategy:
|
14
|
+
fail-fast: false
|
15
|
+
matrix:
|
16
|
+
ruby: [ '2.5', '2.6', '2.7', '3.0' ]
|
17
|
+
os:
|
18
|
+
- ubuntu-latest
|
19
|
+
name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }}
|
20
|
+
steps:
|
21
|
+
- uses: actions/checkout@v2
|
22
|
+
- uses: ruby/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
25
|
+
- name: unit testing
|
26
|
+
env:
|
27
|
+
CI: true
|
28
|
+
run: |
|
29
|
+
gem install bundler rake
|
30
|
+
bundle install --jobs 4 --retry 3
|
31
|
+
bundle exec rake test
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
## 0.3.5
|
2
|
+
* Confirm Ruby 3.0 ready
|
3
|
+
|
4
|
+
## 0.3.4
|
5
|
+
* Pass chunk directly into builtin placeholders
|
6
|
+
|
7
|
+
## 0.3.3
|
8
|
+
* Add multi workers environment considaration
|
9
|
+
|
10
|
+
## 0.3.2
|
11
|
+
* Add TTL support
|
12
|
+
|
13
|
+
## 0.3.1
|
14
|
+
|
15
|
+
* Use public msgpack APIs instead of its internal APIs
|
16
|
+
* Remove needless rescue block
|
17
|
+
|
1
18
|
## 0.3.0
|
2
19
|
|
3
20
|
* Migrate v0.14 API based plugin
|
@@ -38,4 +55,3 @@
|
|
38
55
|
## 0.0.1
|
39
56
|
|
40
57
|
* This initial plugin is released.
|
41
|
-
|
data/{README.rdoc → README.md}
RENAMED
@@ -1,18 +1,18 @@
|
|
1
|
-
|
1
|
+
# Redis output plugin for Fluent
|
2
2
|
|
3
3
|
fluent-plugin-redis is a fluent plugin to output to redis.
|
4
4
|
|
5
|
-
|
5
|
+
## Requirements
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
|fluent-plugin-redis| fluentd | ruby |
|
8
|
+
|-------------------|------------------|--------|
|
9
|
+
| >= 0.3.0 | >= 0.14.8 | >= 2.1 |
|
10
|
+
| == 0.2.3 | ~> 0.12.0 * | >= 1.9 |
|
11
|
+
| < 0.2.3 | >= 0.10.0, < 2 * | >= 1.9 |
|
12
12
|
|
13
|
-
|
13
|
+
* May not support all future fluentd features
|
14
14
|
|
15
|
-
|
15
|
+
## Installation
|
16
16
|
|
17
17
|
What you have to do is only installing like this:
|
18
18
|
|
@@ -20,7 +20,7 @@ What you have to do is only installing like this:
|
|
20
20
|
|
21
21
|
Then fluent automatically loads the plugin installed.
|
22
22
|
|
23
|
-
|
23
|
+
## Configuration
|
24
24
|
|
25
25
|
<match redis.**>
|
26
26
|
@type redis
|
@@ -40,17 +40,30 @@ Then fluent automatically loads the plugin installed.
|
|
40
40
|
# strftime_format "%s"
|
41
41
|
# Allow insert key duplicate. It will work as update values.
|
42
42
|
# allow_duplicate_key true
|
43
|
+
# ttl 300 # If 0 or negative value is set, ttl is not set in each key.
|
43
44
|
</match>
|
44
45
|
|
46
|
+
### With multi workers
|
45
47
|
|
46
|
-
|
48
|
+
fluent-plugin-redis can handle <em>multi workers</em>.
|
49
|
+
This feature can be enabled with the following configuration:
|
50
|
+
|
51
|
+
<system>
|
52
|
+
workers n # where n >= 2.
|
53
|
+
</system>
|
54
|
+
|
55
|
+
### Notice
|
47
56
|
|
48
57
|
<em>insert_key_prefix</em>, <em>strftime_format</em>, and <em>allow_duplicate_key</em> are newly added config parameters.
|
49
58
|
|
50
59
|
They can use v0.3.0 or later. To use this parameters, users must update Fluentd to v0.14 or later and this plugin to v0.3.0 or later.
|
51
60
|
|
52
|
-
|
53
|
-
|
61
|
+
<em>multi workers</em> are newly introduced feature in Fluentd v0.14.
|
62
|
+
|
63
|
+
It can use this feature in this plugin in v0.3.3 or later.
|
64
|
+
|
65
|
+
## Contributing to fluent-plugin-redis
|
66
|
+
|
54
67
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
55
68
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
56
69
|
* Fork the project
|
@@ -59,8 +72,10 @@ They can use v0.3.0 or later. To use this parameters, users must update Fluentd
|
|
59
72
|
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
60
73
|
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
61
74
|
|
75
|
+
## Copyright
|
76
|
+
|
77
|
+
Copyright (c) 2011- Yuki Nishijima
|
62
78
|
|
63
|
-
|
79
|
+
## License
|
64
80
|
|
65
|
-
|
66
|
-
License:: Apache License, Version 2.0
|
81
|
+
Apache License, Version 2.0
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.1
|
data/fluent-plugin-redis.gemspec
CHANGED
@@ -3,12 +3,12 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "fluent-plugin-redis"
|
6
|
-
s.version = "0.3.
|
6
|
+
s.version = "0.3.5"
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["Yuki Nishijima", "Hiroshi Hatake", "Kenji Okimoto"]
|
9
|
-
s.date = %q{
|
9
|
+
s.date = %q{2019-02-26}
|
10
10
|
s.email = ["mail@yukinishijima.net", "fluent@clear-code.com"]
|
11
|
-
s.homepage = "
|
11
|
+
s.homepage = "https://github.com/fluent-plugins-nursery/fluent-plugin-redis"
|
12
12
|
s.summary = "Redis output plugin for Fluent"
|
13
13
|
|
14
14
|
s.files = `git ls-files`.split("\n")
|
@@ -16,10 +16,11 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
19
|
-
s.add_dependency %q<fluentd>, [">= 0.14.
|
19
|
+
s.add_dependency %q<fluentd>, [">= 0.14.22", "< 2"]
|
20
20
|
s.add_dependency %q<redis>, ["~> 3.3.0"]
|
21
21
|
s.add_development_dependency %q<rake>, [">= 11.3.0"]
|
22
22
|
s.add_development_dependency %q<bundler>
|
23
|
-
s.add_development_dependency %q<test-unit>, ["~> 3.
|
23
|
+
s.add_development_dependency %q<test-unit>, ["~> 3.3.9"]
|
24
24
|
s.add_development_dependency %q<appraisal>, ["~> 2.1.0"]
|
25
|
+
s.add_development_dependency %q<webrick>
|
25
26
|
end
|
@@ -1,17 +1,15 @@
|
|
1
1
|
require 'redis'
|
2
2
|
require 'msgpack'
|
3
|
-
require 'fluent/msgpack_factory'
|
4
3
|
require 'fluent/plugin/output'
|
5
4
|
|
6
5
|
module Fluent::Plugin
|
7
6
|
class RedisOutput < Output
|
8
|
-
include Fluent::MessagePackFactory::Mixin
|
9
|
-
|
10
7
|
Fluent::Plugin.register_output('redis', self)
|
11
8
|
|
12
9
|
helpers :compat_parameters, :inject
|
13
10
|
|
14
11
|
DEFAULT_BUFFER_TYPE = "memory"
|
12
|
+
DEFAULT_TTL_VALUE = -1
|
15
13
|
|
16
14
|
attr_reader :redis
|
17
15
|
|
@@ -22,6 +20,7 @@ module Fluent::Plugin
|
|
22
20
|
config_param :insert_key_prefix, :string, default: "${tag}"
|
23
21
|
config_param :strftime_format, :string, default: "%s"
|
24
22
|
config_param :allow_duplicate_key, :bool, default: false
|
23
|
+
config_param :ttl, :integer, default: DEFAULT_TTL_VALUE
|
25
24
|
|
26
25
|
config_section :buffer do
|
27
26
|
config_set_default :@type, DEFAULT_BUFFER_TYPE
|
@@ -31,6 +30,7 @@ module Fluent::Plugin
|
|
31
30
|
|
32
31
|
def configure(conf)
|
33
32
|
compat_parameters_convert(conf, :buffer, :inject)
|
33
|
+
@running_multi_workers = system_config.workers > 1
|
34
34
|
super
|
35
35
|
|
36
36
|
if conf.has_key?('namespace')
|
@@ -38,6 +38,7 @@ module Fluent::Plugin
|
|
38
38
|
end
|
39
39
|
raise Fluent::ConfigError, "'tag' in chunk_keys is required." if not @chunk_key_tag
|
40
40
|
raise Fluent::ConfigError, "'time' in chunk_keys is required." if not @chunk_key_time
|
41
|
+
@unpacker = Fluent::Engine.msgpack_factory.unpacker
|
41
42
|
end
|
42
43
|
|
43
44
|
def start
|
@@ -68,23 +69,32 @@ module Fluent::Plugin
|
|
68
69
|
true
|
69
70
|
end
|
70
71
|
|
72
|
+
def multi_workers_ready?
|
73
|
+
true
|
74
|
+
end
|
75
|
+
|
71
76
|
def write(chunk)
|
72
|
-
tag, time = expand_placeholders(chunk
|
77
|
+
tag, time = expand_placeholders(chunk)
|
73
78
|
@redis.pipelined {
|
74
79
|
unless @allow_duplicate_key
|
75
|
-
chunk.
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
stream = chunk.to_msgpack_stream
|
81
|
+
@unpacker.feed_each(stream).with_index { |record, index|
|
82
|
+
identifier = if @running_multi_workers
|
83
|
+
[tag, time, fluentd_worker_id].join(".")
|
84
|
+
else
|
85
|
+
[tag, time].join(".")
|
86
|
+
end
|
87
|
+
@redis.multi do
|
88
|
+
@redis.mapped_hmset "#{identifier}.#{index}", record[2]
|
89
|
+
@redis.expire "#{identifier}.#{index}", @ttl if @ttl > 0
|
83
90
|
end
|
84
91
|
}
|
85
92
|
else
|
86
93
|
chunk.each do |_tag, _time, record|
|
87
|
-
@redis.
|
94
|
+
@redis.multi do
|
95
|
+
@redis.mapped_hmset "#{tag}", record
|
96
|
+
@redis.expire "#{tag}", @ttl if @ttl > 0
|
97
|
+
end
|
88
98
|
end
|
89
99
|
end
|
90
100
|
}
|
@@ -92,9 +102,9 @@ module Fluent::Plugin
|
|
92
102
|
|
93
103
|
private
|
94
104
|
|
95
|
-
def expand_placeholders(
|
96
|
-
tag = extract_placeholders(@insert_key_prefix,
|
97
|
-
time = extract_placeholders(@strftime_format,
|
105
|
+
def expand_placeholders(chunk)
|
106
|
+
tag = extract_placeholders(@insert_key_prefix, chunk)
|
107
|
+
time = extract_placeholders(@strftime_format, chunk)
|
98
108
|
return tag, time
|
99
109
|
end
|
100
110
|
end
|
@@ -36,6 +36,7 @@ class FileOutputTest < Test::Unit::TestCase
|
|
36
36
|
assert_equal '${tag}', @d.instance.insert_key_prefix
|
37
37
|
assert_equal '%s', @d.instance.strftime_format
|
38
38
|
assert_false @d.instance.allow_duplicate_key
|
39
|
+
assert_equal Fluent::Plugin::RedisOutput::DEFAULT_TTL_VALUE, @d.instance.ttl
|
39
40
|
end
|
40
41
|
|
41
42
|
def test_configure_with_password
|
@@ -116,8 +117,25 @@ class FileOutputTest < Test::Unit::TestCase
|
|
116
117
|
d.feed(time, {"a"=>3})
|
117
118
|
end
|
118
119
|
|
119
|
-
assert_equal "2", d.instance.redis.hget("
|
120
|
-
assert_equal "3", d.instance.redis.hget("
|
120
|
+
assert_equal "2", d.instance.redis.hget("test.#{time}.0", "a")
|
121
|
+
assert_equal "3", d.instance.redis.hget("test.#{time}.1", "a")
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_write_with_ttl
|
125
|
+
ttl = 2
|
126
|
+
d = create_driver CONFIG + %[
|
127
|
+
ttl #{ttl}
|
128
|
+
allow_duplicate_key true
|
129
|
+
]
|
130
|
+
time = event_time("2011-01-02 13:14:00 UTC")
|
131
|
+
d.run(default_tag: 'ttl.insert.test') do
|
132
|
+
d.feed(time, {"a"=>2})
|
133
|
+
end
|
134
|
+
|
135
|
+
assert_in_delta 2.0, d.instance.redis.ttl("ttl.insert.test"), 1.0
|
136
|
+
|
137
|
+
sleep ttl+1
|
138
|
+
assert_equal -2, d.instance.redis.ttl("ttl.insert.test")
|
121
139
|
end
|
122
140
|
|
123
141
|
def test_write_with_custom_strftime_format
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuki Nishijima
|
8
8
|
- Hiroshi Hatake
|
9
9
|
- Kenji Okimoto
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2019-02-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: fluentd
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.14.
|
21
|
+
version: 0.14.22
|
22
22
|
- - "<"
|
23
23
|
- !ruby/object:Gem::Version
|
24
24
|
version: '2'
|
@@ -28,7 +28,7 @@ dependencies:
|
|
28
28
|
requirements:
|
29
29
|
- - ">="
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
version: 0.14.
|
31
|
+
version: 0.14.22
|
32
32
|
- - "<"
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '2'
|
@@ -80,14 +80,14 @@ dependencies:
|
|
80
80
|
requirements:
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: 3.
|
83
|
+
version: 3.3.9
|
84
84
|
type: :development
|
85
85
|
prerelease: false
|
86
86
|
version_requirements: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: 3.
|
90
|
+
version: 3.3.9
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: appraisal
|
93
93
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,7 +102,21 @@ dependencies:
|
|
102
102
|
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: 2.1.0
|
105
|
-
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: webrick
|
107
|
+
requirement: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
type: :development
|
113
|
+
prerelease: false
|
114
|
+
version_requirements: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
description:
|
106
120
|
email:
|
107
121
|
- mail@yukinishijima.net
|
108
122
|
- fluent@clear-code.com
|
@@ -110,11 +124,12 @@ executables: []
|
|
110
124
|
extensions: []
|
111
125
|
extra_rdoc_files: []
|
112
126
|
files:
|
127
|
+
- ".github/ISSUE_TEMPLATE.md"
|
128
|
+
- ".github/workflows/linux.yml"
|
113
129
|
- ".gitignore"
|
114
|
-
- ".travis.yml"
|
115
130
|
- CHANGELOG.md
|
116
131
|
- Gemfile
|
117
|
-
- README.
|
132
|
+
- README.md
|
118
133
|
- Rakefile
|
119
134
|
- VERSION
|
120
135
|
- fluent-plugin-redis.gemspec
|
@@ -123,10 +138,10 @@ files:
|
|
123
138
|
- gemfiles/fluentd_v0.14.gemfile
|
124
139
|
- lib/fluent/plugin/out_redis.rb
|
125
140
|
- test/plugin/test_out_redis.rb
|
126
|
-
homepage:
|
141
|
+
homepage: https://github.com/fluent-plugins-nursery/fluent-plugin-redis
|
127
142
|
licenses: []
|
128
143
|
metadata: {}
|
129
|
-
post_install_message:
|
144
|
+
post_install_message:
|
130
145
|
rdoc_options: []
|
131
146
|
require_paths:
|
132
147
|
- lib
|
@@ -141,9 +156,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
156
|
- !ruby/object:Gem::Version
|
142
157
|
version: '0'
|
143
158
|
requirements: []
|
144
|
-
|
145
|
-
|
146
|
-
signing_key:
|
159
|
+
rubygems_version: 3.1.2
|
160
|
+
signing_key:
|
147
161
|
specification_version: 4
|
148
162
|
summary: Redis output plugin for Fluent
|
149
163
|
test_files:
|