fluent-plugin-redis 0.3.1 → 0.3.2

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: 772672c27bf0f6509a2929ab120c75f95796e62d
4
- data.tar.gz: d9438be5e6fee77d90e296fd3f68c3cf108b6e01
3
+ metadata.gz: fc6961a6fa218ce3d3f85c2a26edba0cb83080f7
4
+ data.tar.gz: de3f5f6a4c21b6b81cd1a3f3dd1f5c91ac2ee2e0
5
5
  SHA512:
6
- metadata.gz: a7c8f61082e5b520f01e583e22cc0f6e7b40ba480924ec2017b11e1320dfb0e781f5a27728c6eef51d93836e37ab8098d479f55168ac21f8a0bc5955cab09e16
7
- data.tar.gz: d938a143d5ce6954c671bf666360aa1ce6c354438753b823bb6ce8940e73d166d051a578f231a04405e93f70518bdaa375e3a1700ac4fadb07a7c7a8a3845b8c
6
+ metadata.gz: ceef0bf6b9f63cc7910fb2f8c0ac420ff079fdd98313b5c1aad2d84fa5de75d38a51ce482b402ab693fb1f8f268ee77860e5730bc7a0868af1ad0122de6120ae
7
+ data.tar.gz: a7a186abedc53853bfaf5dc0526ddd0a906d69ef274a035c1dc8307761f410c30de7e1a8a36ef79005feb72269850ab8851cb9472274beea5e19c5a294b5b7f8
data/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## 0.3.1
2
2
 
3
- * Use public msgpack related API instead of internal its API
3
+ * Use public msgpack APIs instead of its internal APIs
4
4
  * Remove needless rescue block
5
5
 
6
6
  ## 0.3.0
@@ -1,18 +1,18 @@
1
- = Redis output plugin for Fluent
1
+ # Redis output plugin for Fluent
2
2
 
3
3
  fluent-plugin-redis is a fluent plugin to output to redis.
4
4
 
5
- == Requirements
5
+ ## Requirements
6
6
 
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 |
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
- * May not support all future fluentd features
13
+ * May not support all future fluentd features
14
14
 
15
- == Installation
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
- == Configuration
23
+ ## Configuration
24
24
 
25
25
  <match redis.**>
26
26
  @type redis
@@ -40,16 +40,17 @@ 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
 
45
46
 
46
- === Notice
47
+ ### Notice
47
48
 
48
49
  <em>insert_key_prefix</em>, <em>strftime_format</em>, and <em>allow_duplicate_key</em> are newly added config parameters.
49
50
 
50
51
  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
52
 
52
- == Contributing to fluent-plugin-redis
53
+ ## Contributing to fluent-plugin-redis
53
54
 
54
55
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
55
56
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
@@ -59,8 +60,10 @@ They can use v0.3.0 or later. To use this parameters, users must update Fluentd
59
60
  * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
60
61
  * 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
62
 
63
+ ## Copyright
62
64
 
63
- == Copyright
65
+ Copyright (c) 2011- Yuki Nishijima
64
66
 
65
- Copyright:: Copyright (c) 2011- Yuki Nishijima
66
- License:: Apache License, Version 2.0
67
+ ## License
68
+
69
+ Apache License, Version 2.0
@@ -3,10 +3,10 @@ $:.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.1"
6
+ s.version = "0.3.2"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Yuki Nishijima", "Hiroshi Hatake", "Kenji Okimoto"]
9
- s.date = %q{2017-01-05}
9
+ s.date = %q{2017-03-27}
10
10
  s.email = ["mail@yukinishijima.net", "fluent@clear-code.com"]
11
11
  s.homepage = "https://github.com/fluent-plugins-nursery/fluent-plugin-redis"
12
12
  s.summary = "Redis output plugin for Fluent"
@@ -9,6 +9,7 @@ module Fluent::Plugin
9
9
  helpers :compat_parameters, :inject
10
10
 
11
11
  DEFAULT_BUFFER_TYPE = "memory"
12
+ DEFAULT_TTL_VALUE = -1
12
13
 
13
14
  attr_reader :redis
14
15
 
@@ -19,6 +20,7 @@ module Fluent::Plugin
19
20
  config_param :insert_key_prefix, :string, default: "${tag}"
20
21
  config_param :strftime_format, :string, default: "%s"
21
22
  config_param :allow_duplicate_key, :bool, default: false
23
+ config_param :ttl, :integer, default: DEFAULT_TTL_VALUE
22
24
 
23
25
  config_section :buffer do
24
26
  config_set_default :@type, DEFAULT_BUFFER_TYPE
@@ -73,11 +75,17 @@ module Fluent::Plugin
73
75
  stream = chunk.to_msgpack_stream
74
76
  @unpacker.feed_each(stream).with_index { |record, index|
75
77
  identifier = [tag, time].join(".")
76
- @redis.mapped_hmset "#{identifier}.#{index}", record[2]
78
+ @redis.multi do
79
+ @redis.mapped_hmset "#{identifier}.#{index}", record[2]
80
+ @redis.expire "#{identifier}.#{index}", @ttl if @ttl > 0
81
+ end
77
82
  }
78
83
  else
79
84
  chunk.each do |_tag, _time, record|
80
- @redis.mapped_hmset "#{tag}", record
85
+ @redis.multi do
86
+ @redis.mapped_hmset "#{tag}", record
87
+ @redis.expire "#{tag}", @ttl if @ttl > 0
88
+ end
81
89
  end
82
90
  end
83
91
  }
@@ -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("insert.test.#{time}.0", "a")
120
- assert_equal "3", d.instance.redis.hget("insert.test.#{time}.1", "a")
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuki Nishijima
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-01-05 00:00:00.000000000 Z
13
+ date: 2017-03-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: fluentd
@@ -114,7 +114,7 @@ files:
114
114
  - ".travis.yml"
115
115
  - CHANGELOG.md
116
116
  - Gemfile
117
- - README.rdoc
117
+ - README.md
118
118
  - Rakefile
119
119
  - VERSION
120
120
  - fluent-plugin-redis.gemspec