fluent-plugin-memcached 0.0.5 → 0.0.6

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: 687484353d1845d26e83e4317d0fb046afe7825a
4
- data.tar.gz: 1ee6c8f8a305578685e56989ec85ae27472e0cd9
3
+ metadata.gz: da645ae2f7d674fe83ee1c49746d5f27e391af15
4
+ data.tar.gz: ab6d4e05276efecf24f1d97f9e2169970e08bda2
5
5
  SHA512:
6
- metadata.gz: b711578a988b4e8e199cd921b4f84deaac9426c9a4537936393132237adc1676f746fe14c06f5787d11dc28e0231b794158328c5d68badfc144ae967d0ea1485
7
- data.tar.gz: e312cca1312d2cd41e297544c5b5710f8eb83578697fe5f6fda995fbb24abe81f8401ab2e2cdc6a09c29344922d127250480904cd159e5171b7217de6260f1f4
6
+ metadata.gz: 7e44da1a22c1f1534934c57ee2595176b1607b2077862d4400530d7763f8302595437692cea143b91d9a8e816638f2d238db9aed4113fe82e00f05a8bbfcc7be
7
+ data.tar.gz: 037e6872ef6b7a42be7083a250161dde433daf8576e82f62099f302b14c9650d5234842461bddd05d4fb8a894c2373b3468f8f5b74d8d3a39108d4d62c17220d
data/README.md CHANGED
@@ -20,6 +20,7 @@ Default values would look like this:
20
20
  type memcached
21
21
  host localhost
22
22
  port 11211
23
+ # value_separater " "
23
24
  </match>
24
25
  ```
25
26
 
@@ -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.5"
7
+ gem.version = "0.0.6"
8
8
  gem.authors = ["innossh"]
9
9
  gem.email = ["innossh@users.noreply.github.com"]
10
10
 
@@ -4,6 +4,7 @@ class Fluent::MemcachedOutput < Fluent::BufferedOutput
4
4
  config_param :host, :string, :default => 'localhost'
5
5
  config_param :port, :integer, :default => 11211
6
6
 
7
+ config_param :value_separater, :string, :default => ' '
7
8
  config_param :value_format, :string, :default => 'raw'
8
9
  config_param :param_names, :string, :default => nil # nil doesn't allowed for json
9
10
 
@@ -20,7 +21,7 @@ class Fluent::MemcachedOutput < Fluent::BufferedOutput
20
21
  if @value_format == 'json' and @param_names.nil?
21
22
  raise Fluent::ConfigError, "param_names MUST be specified in the case of json format"
22
23
  end
23
- @formatter = RecordValueFormatter.new(@value_format, @param_names)
24
+ @formatter = RecordValueFormatter.new(@value_separater, @value_format, @param_names)
24
25
  end
25
26
 
26
27
  def start
@@ -43,10 +44,12 @@ class Fluent::MemcachedOutput < Fluent::BufferedOutput
43
44
  end
44
45
 
45
46
  class RecordValueFormatter
47
+ attr_reader :value_separater
46
48
  attr_reader :value_format
47
49
  attr_reader :param_names
48
50
 
49
- def initialize(value_format, param_names)
51
+ def initialize(value_separater, value_format, param_names)
52
+ @value_separater = value_separater
50
53
  @value_format = value_format
51
54
  @param_names = param_names
52
55
  end
@@ -65,7 +68,7 @@ class Fluent::MemcachedOutput < Fluent::BufferedOutput
65
68
  }
66
69
  hash.to_json
67
70
  else
68
- record.values.drop(1).join(' ')
71
+ record.values.drop(1).join(@value_separater)
69
72
  end
70
73
  end
71
74
  end
@@ -19,23 +19,27 @@ class MemcachedOutputTest < Test::Unit::TestCase
19
19
  param_names param1,param2
20
20
  ]
21
21
 
22
+ CONFIG_MYSQL = %[
23
+ host 127.0.0.1
24
+ port 11211
25
+ value_separater |
26
+ ]
27
+
22
28
  def create_driver(conf = CONFIG, tag='test')
23
29
  Fluent::Test::BufferedOutputTestDriver.new(Fluent::MemcachedOutput, tag).configure(conf)
24
30
  end
25
31
 
26
32
  def test_configure
27
33
  d = create_driver('')
28
-
29
34
  assert_equal 'localhost', d.instance.host
30
35
  assert_equal 11211, d.instance.port
36
+ assert_equal ' ', d.instance.value_separater
31
37
 
32
38
  d = create_driver
33
-
34
39
  assert_equal '127.0.0.1', d.instance.host
35
40
  assert_equal 11211, d.instance.port
36
41
 
37
42
  d = create_driver(CONFIG_JSON)
38
-
39
43
  assert_equal '127.0.0.1', d.instance.host
40
44
  assert_equal 11211, d.instance.port
41
45
  assert_equal 'json', d.instance.value_format
@@ -48,6 +52,11 @@ class MemcachedOutputTest < Test::Unit::TestCase
48
52
  value_format json
49
53
  ]
50
54
  }
55
+
56
+ d = create_driver(CONFIG_MYSQL)
57
+ assert_equal '127.0.0.1', d.instance.host
58
+ assert_equal 11211, d.instance.port
59
+ assert_equal '|', d.instance.value_separater
51
60
  end
52
61
 
53
62
  def test_format
@@ -87,4 +96,14 @@ class MemcachedOutputTest < Test::Unit::TestCase
87
96
  assert_equal record2_value_json, d.instance.memcached.get('d')
88
97
  end
89
98
 
99
+ def test_write_to_mysql
100
+ d = create_driver(CONFIG_MYSQL)
101
+ time = Time.parse('2011-01-02 13:14:15 UTC').to_i
102
+ record = {'key' => time, 'metrics_name' => 'count', 'metrics_value' => '100'}
103
+ d.emit(record, time)
104
+ d.run
105
+
106
+ assert_equal 'count|100', d.instance.memcached.get(time)
107
+ end
108
+
90
109
  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.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - innossh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-27 00:00:00.000000000 Z
11
+ date: 2015-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd