fluent-plugin-memcached 0.0.7 → 0.1.0

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: ecd435b2a7544144b0d4491bf27dcdbde3983616
4
- data.tar.gz: 7ba5ef4be3af483784dbe95a09215bb85a2cad36
3
+ metadata.gz: 04bdd171af2653d194e71653ef1cde7b3f5d8eac
4
+ data.tar.gz: 7bc7d5f2c588e61462fa79f27c8bdcb8ac478552
5
5
  SHA512:
6
- metadata.gz: 1e45543bc50066e97449d032c5e40455471dda3c85fa4f3154e45ae25071f33a13548227282e5a916396568d28747a845cf124054d9edeb565146b57e8d2f5ec
7
- data.tar.gz: 086c2879c5f2c9bcd366ed14c3483a7f8049a3985ff503a78fdf802d66feb6046b43ad55a985cf3c593fba2e499ce0dbd5d61f7578f237b4bf76b7eefe4f781b
6
+ metadata.gz: a52eb5e76a3feb31c8f6e9410c9ea3c1f463150a7ff2a8a3ce1e64d15746bfb05d65410575b4ef3bed7d7a08890ccfee1826b4b32a9db5f6aa7e934873b4568d
7
+ data.tar.gz: f4763100a95b54f8d2101f20862e0a5dc766aa5446f1b3d0e0a2dc8c1a49a07af2056dc19a68933a2432ea84783275f51829b377d7b749b9f287952415427e79
data/.travis.yml CHANGED
@@ -1,10 +1,12 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 1.9.3
5
- - 2.0.0
6
4
  - 2.1
7
5
  - 2.2
6
+ - 2.3.4
7
+ - 2.4.1
8
8
 
9
+ before_install:
10
+ - gem update bundler
9
11
  services:
10
12
  - memcached
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Fluent::Plugin::Memcached, a plugin for [Fluentd](http://www.fluentd.org)
2
2
 
3
3
  [![Build Status](https://travis-ci.org/innossh/fluent-plugin-memcached.svg?branch=master)](https://travis-ci.org/innossh/fluent-plugin-memcached)
4
+ [![Gem Version](https://badge.fury.io/rb/fluent-plugin-memcached.svg)](https://badge.fury.io/rb/fluent-plugin-memcached)
4
5
 
5
6
  Send your logs to Memcached.
6
7
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "fluent-plugin-memcached"
7
- gem.version = "0.0.7"
7
+ gem.version = "0.1.0"
8
8
  gem.authors = ["innossh"]
9
9
  gem.email = ["innossh@users.noreply.github.com"]
10
10
 
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
- gem.add_runtime_dependency "fluentd"
20
+ gem.add_runtime_dependency "fluentd", [">= 0.14.15", "< 2"]
21
21
  gem.add_runtime_dependency "dalli"
22
22
  gem.add_development_dependency "rake"
23
23
  gem.add_development_dependency "test-unit"
@@ -1,4 +1,7 @@
1
- class Fluent::MemcachedOutput < Fluent::BufferedOutput
1
+ require 'dalli'
2
+ require 'fluent/plugin/output'
3
+
4
+ class Fluent::Plugin::MemcachedOutput < Fluent::Plugin::Output
2
5
  Fluent::Plugin.register_output('memcached', self)
3
6
 
4
7
  config_param :host, :string, :default => 'localhost'
@@ -13,11 +16,6 @@ class Fluent::MemcachedOutput < Fluent::BufferedOutput
13
16
  attr_accessor :memcached
14
17
  attr_accessor :formatter
15
18
 
16
- def initialize
17
- super
18
- require 'dalli'
19
- end
20
-
21
19
  def configure(conf)
22
20
  super
23
21
  if @value_format == 'json' and @param_names.nil?
@@ -33,12 +31,21 @@ class Fluent::MemcachedOutput < Fluent::BufferedOutput
33
31
 
34
32
  def shutdown
35
33
  @memcached.close
34
+ super
36
35
  end
37
36
 
38
37
  def format(tag, time, record)
39
38
  [tag, time, record].to_msgpack
40
39
  end
41
40
 
41
+ def formatted_to_msgpack_binary?
42
+ true
43
+ end
44
+
45
+ def multi_workers_ready?
46
+ true
47
+ end
48
+
42
49
  def write(chunk)
43
50
  chunk.msgpack_each { |tag, time, record|
44
51
  key = @formatter.key(record)
@@ -1,8 +1,12 @@
1
1
  require 'test/unit'
2
2
  require 'fluent/test'
3
+ require 'fluent/test/helpers'
4
+ require 'fluent/test/driver/output'
3
5
  require 'fluent/plugin/out_memcached'
4
6
 
5
7
  class MemcachedOutputTest < Test::Unit::TestCase
8
+ include Fluent::Test::Helpers
9
+
6
10
  def setup
7
11
  Fluent::Test.setup
8
12
  end
@@ -31,8 +35,8 @@ class MemcachedOutputTest < Test::Unit::TestCase
31
35
  value_separater |
32
36
  ]
33
37
 
34
- def create_driver(conf = CONFIG, tag='test')
35
- Fluent::Test::BufferedOutputTestDriver.new(Fluent::MemcachedOutput, tag).configure(conf)
38
+ def create_driver(conf = CONFIG)
39
+ Fluent::Test::Driver::Output.new(Fluent::Plugin::MemcachedOutput).configure(conf)
36
40
  end
37
41
 
38
42
  def test_configure
@@ -75,19 +79,21 @@ class MemcachedOutputTest < Test::Unit::TestCase
75
79
  d = create_driver
76
80
  time = Time.parse('2011-01-02 13:14:15 UTC').to_i
77
81
  record = {'key' => 'key', 'param1' => 'value'}
78
- d.emit(record, time)
79
- d.expect_format(['test', time, record].to_msgpack)
80
- d.run
82
+ d.run(default_tag: 'test') do
83
+ d.feed(time, record)
84
+ end
85
+ assert_equal [['test', time, record].to_msgpack], d.formatted
81
86
  end
82
87
 
83
88
  def test_write
84
89
  d = create_driver
85
- time = Time.parse('2011-01-02 13:14:15 UTC').to_i
90
+ time = event_time('2011-01-02 13:14:15 UTC')
86
91
  record1 = {'key' => 'a', 'param1' => '1'}
87
92
  record2 = {'key' => 'b', 'param1' => '2', 'param2' => '3'}
88
- d.emit(record1, time)
89
- d.emit(record2, time)
90
- d.run
93
+ d.run(default_tag: 'test') do
94
+ d.feed(time, record1)
95
+ d.feed(time, record2)
96
+ end
91
97
 
92
98
  assert_equal '1', d.instance.memcached.get('a')
93
99
  assert_equal '2 3', d.instance.memcached.get('b')
@@ -95,42 +101,51 @@ class MemcachedOutputTest < Test::Unit::TestCase
95
101
 
96
102
  def test_write_json
97
103
  d = create_driver(CONFIG_JSON)
98
- time = Time.parse('2011-01-02 13:14:15 UTC').to_i
104
+ time = event_time('2011-01-02 13:14:15 UTC')
99
105
  record1 = {'key' => 'c', 'param1' => '4'}
100
106
  record2 = {'key' => 'd', 'param1' => '5', 'param2' => '6'}
101
107
  record1_value_json = {'param1' => '4', 'param2' => nil}.to_json
102
108
  record2_value_json = {'param1' => '5', 'param2' => '6'}.to_json
103
- d.emit(record1, time)
104
- d.emit(record2, time)
105
- d.run
109
+ d.run(default_tag: 'test') do
110
+ d.feed(time, record1)
111
+ d.feed(time, record2)
112
+ end
106
113
 
107
114
  assert_equal record1_value_json, d.instance.memcached.get('c')
108
115
  assert_equal record2_value_json, d.instance.memcached.get('d')
109
116
  end
110
117
 
111
- def test_write_increment
112
- d = create_driver(CONFIG_INCREMENT)
113
- time = Time.parse('2011-01-02 13:14:15 UTC').to_i
114
- record1 = {'key' => 'count1', 'param1' => 1}
115
- record2 = {'key' => 'count2', 'param1' => 2}
116
- record3 = {'key' => 'count1', 'param1' => 3}
117
- record4 = {'key' => 'count2', 'param1' => 4}
118
- d.emit(record1, time)
119
- d.emit(record2, time)
120
- d.emit(record3, time)
121
- d.emit(record4, time)
122
- d.run
123
-
124
- assert_equal (1 + 3), d.instance.memcached.get('count1').to_i
125
- assert_equal (2 + 4), d.instance.memcached.get('count2').to_i
118
+ class IncrementTest < self
119
+ def teardown
120
+ @d.instance.memcached.flush_all
121
+ end
122
+
123
+ def test_write_increment
124
+ @d = create_driver(CONFIG_INCREMENT)
125
+ time = event_time('2011-01-02 13:14:15 UTC')
126
+ record1 = {'key' => 'count1', 'param1' => 1}
127
+ record2 = {'key' => 'count2', 'param1' => 2}
128
+ record3 = {'key' => 'count1', 'param1' => 3}
129
+ record4 = {'key' => 'count2', 'param1' => 4}
130
+ @d.run(default_tag: 'test') do
131
+ @d.feed(time, record1)
132
+ @d.feed(time, record2)
133
+ @d.feed(time, record3)
134
+ @d.feed(time, record4)
135
+ end
136
+
137
+ assert_equal (1 + 3), @d.instance.memcached.get('count1').to_i
138
+ assert_equal (2 + 4), @d.instance.memcached.get('count2').to_i
139
+ end
126
140
  end
127
141
 
128
142
  def test_write_to_mysql
129
143
  d = create_driver(CONFIG_MYSQL)
130
- time = Time.parse('2011-01-02 13:14:15 UTC').to_i
144
+ time = event_time('2011-01-02 13:14:15 UTC')
131
145
  record = {'key' => time, 'metrics_name' => 'count', 'metrics_value' => '100'}
132
- d.emit(record, time)
133
- d.run
146
+ d.run(default_tag: 'test') do
147
+ d.feed(time, record)
148
+ end
134
149
 
135
150
  assert_equal 'count|100', d.instance.memcached.get(time)
136
151
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-memcached
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - innossh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-01 00:00:00.000000000 Z
11
+ date: 2017-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -16,14 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.14.15
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '0'
29
+ version: 0.14.15
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: dalli
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -101,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
107
  version: '0'
102
108
  requirements: []
103
109
  rubyforge_project:
104
- rubygems_version: 2.4.5.1
110
+ rubygems_version: 2.6.8
105
111
  signing_key:
106
112
  specification_version: 4
107
113
  summary: Memcached output plugin for Fluent