fluent-plugin-mqtt 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/fluent-plugin-mqtt.gemspec +1 -1
- data/lib/fluent/plugin/in_mqtt.rb +9 -2
- data/test/plugin/test_in_mqtt.rb +15 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4e453c77b000aeef76dbe664b9fb67d63a6e532
|
4
|
+
data.tar.gz: f22a3f8159fdfc1bc4571619406534292a082652
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d38f63aaabf190906296242b259ad742c9f43d659abda789dda94007d34271caa68852a2976626207c1285ca8d060a7682effe8251977bdb0ca301d958e9ec56
|
7
|
+
data.tar.gz: 972613c5cd9484810ba8757577748781a9659404dba58459e572183a22986dc682e39482b45b85ed6266737b2bcfef1cb66ce726881765cbf4d54076cdbb3cf1
|
data/fluent-plugin-mqtt.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "fluent-plugin-mqtt"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.3"
|
8
8
|
spec.authors = ["Yuuna Kurita"]
|
9
9
|
spec.email = ["yuuna.m@gmail.com"]
|
10
10
|
spec.summary = %q{fluentd input plugin for mqtt server}
|
@@ -22,7 +22,7 @@ module Fluent
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def start
|
25
|
-
$log.debug "start mqtt"
|
25
|
+
$log.debug "start mqtt #{@bind}"
|
26
26
|
@connect = MQTT::Client.connect({remote_host: @bind, remote_port: @port})
|
27
27
|
@connect.subscribe(@topic)
|
28
28
|
|
@@ -36,7 +36,14 @@ module Fluent
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def emit topic, message , time = Fluent::Engine.now
|
39
|
-
|
39
|
+
if message.class == Array
|
40
|
+
message.each do |data|
|
41
|
+
$log.debug "#{topic}: #{data}"
|
42
|
+
Fluent::Engine.emit(topic , time , data)
|
43
|
+
end
|
44
|
+
else
|
45
|
+
Fluent::Engine.emit(topic , time , message)
|
46
|
+
end
|
40
47
|
end
|
41
48
|
|
42
49
|
def json_parse message
|
data/test/plugin/test_in_mqtt.rb
CHANGED
@@ -1,9 +1,17 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class Fluent::MqttInput
|
4
|
-
def emit topic, message, time = Fluent::Engine.now
|
5
|
-
|
4
|
+
def emit topic, message , time = Fluent::Engine.now
|
5
|
+
if message.class == Array
|
6
|
+
message.each do |data|
|
7
|
+
$log.debug "#{topic}: #{data}"
|
8
|
+
Fluent::Engine.emit(topic, message["t"], data)
|
9
|
+
end
|
10
|
+
else
|
11
|
+
Fluent::Engine.emit(topic, message["t"], message)
|
12
|
+
end
|
6
13
|
end
|
14
|
+
|
7
15
|
end
|
8
16
|
|
9
17
|
class MqttInputTest < Test::Unit::TestCase
|
@@ -41,12 +49,17 @@ class MqttInputTest < Test::Unit::TestCase
|
|
41
49
|
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
42
50
|
d.expect_emit "tag1", time, {"t" => time, "v" => {"a"=>1}}
|
43
51
|
d.expect_emit "tag2", time, {"t" => time, "v" => {"a"=>2}}
|
52
|
+
d.expect_emit "tag3", time, {"t" => time, "v" => {"a"=>31}}
|
53
|
+
d.expect_emit "tag3", time, {"t" => time, "v" => {"a"=>32}}
|
54
|
+
|
44
55
|
d.run do
|
45
56
|
d.expected_emits.each {|tag,time,record|
|
46
57
|
send_data tag, time, record
|
47
58
|
}
|
59
|
+
send_data "tag3", time , [{"t" => time, "v" => {"a"=>31}} , {"t" => time, "v" => {"a"=>32}}]
|
48
60
|
sleep 0.5
|
49
61
|
end
|
62
|
+
|
50
63
|
end
|
51
64
|
|
52
65
|
def send_data tag, time, record
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-mqtt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuuna Kurita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|