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 +4 -4
- data/.travis.yml +4 -2
- data/README.md +1 -0
- data/fluent-plugin-memcached.gemspec +2 -2
- data/lib/fluent/plugin/out_memcached.rb +13 -6
- data/test/plugin/test_out_memcached.rb +46 -31
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04bdd171af2653d194e71653ef1cde7b3f5d8eac
|
4
|
+
data.tar.gz: 7bc7d5f2c588e61462fa79f27c8bdcb8ac478552
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a52eb5e76a3feb31c8f6e9410c9ea3c1f463150a7ff2a8a3ce1e64d15746bfb05d65410575b4ef3bed7d7a08890ccfee1826b4b32a9db5f6aa7e934873b4568d
|
7
|
+
data.tar.gz: f4763100a95b54f8d2101f20862e0a5dc766aa5446f1b3d0e0a2dc8c1a49a07af2056dc19a68933a2432ea84783275f51829b377d7b749b9f287952415427e79
|
data/.travis.yml
CHANGED
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
|
+
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
|
-
|
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
|
35
|
-
Fluent::Test::
|
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.
|
79
|
-
|
80
|
-
|
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 =
|
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.
|
89
|
-
|
90
|
-
|
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 =
|
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.
|
104
|
-
|
105
|
-
|
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
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
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 =
|
144
|
+
time = event_time('2011-01-02 13:14:15 UTC')
|
131
145
|
record = {'key' => time, 'metrics_name' => 'count', 'metrics_value' => '100'}
|
132
|
-
d.
|
133
|
-
|
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
|
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:
|
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:
|
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:
|
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.
|
110
|
+
rubygems_version: 2.6.8
|
105
111
|
signing_key:
|
106
112
|
specification_version: 4
|
107
113
|
summary: Memcached output plugin for Fluent
|