fluent-plugin-sakuraio 0.1.1 → 0.1.2
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-sakuraio.gemspec +1 -1
- data/lib/fluent/plugin/out_sakuraio.rb +13 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e9d59261a7e3f994e9f1f71e8dc15b1daf306cc
|
4
|
+
data.tar.gz: 829c7511c98f93f3de30a98f44a97afd05b28cd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30b2729b21454594fb0de8a06929b10d89b337f1e6b75766cb55e308e76d8d91f7814021983ab6f77681792e68664e23cae2346145ba28c0eebaa0ecba3c7199
|
7
|
+
data.tar.gz: 9e0b1a3e6dc1e49ff38e518a7683c7a251feadd69363c03bec10023707ea61f579665e7bacdeff3996f6e3d0ee239671d53e5913a32138d056bf1c3f4dbeb757
|
@@ -14,7 +14,6 @@ module Fluent::Plugin
|
|
14
14
|
def configure(conf)
|
15
15
|
super
|
16
16
|
|
17
|
-
@client = Faye::WebSocket::Client.new(@url)
|
18
17
|
ensure_reactor_running
|
19
18
|
thread_create(:out_sakuraio, &method(:run))
|
20
19
|
end
|
@@ -27,11 +26,16 @@ module Fluent::Plugin
|
|
27
26
|
end
|
28
27
|
|
29
28
|
def run()
|
29
|
+
@client = Faye::WebSocket::Client.new(@url)
|
30
30
|
EM.next_tick do
|
31
31
|
@client.on :open do
|
32
32
|
log.info "sakuraio: starting websocket connection for #{@url}."
|
33
33
|
end
|
34
34
|
|
35
|
+
@client.on :message do |event|
|
36
|
+
log.debug "sakuraio: received message #{event.data}"
|
37
|
+
end
|
38
|
+
|
35
39
|
@client.on :error do |event|
|
36
40
|
log.warn "sakuraio: #{event.message}"
|
37
41
|
end
|
@@ -45,19 +49,24 @@ module Fluent::Plugin
|
|
45
49
|
def process(_tag, es)
|
46
50
|
es.each do |_time, record|
|
47
51
|
log.debug "sakuraio: process record #{record}"
|
48
|
-
|
52
|
+
modules.each do |m|
|
53
|
+
s = encode_record(m, record)
|
54
|
+
log.debug "sakuraio: encoded json #{s}"
|
55
|
+
@client.send(s)
|
56
|
+
end
|
49
57
|
end
|
50
58
|
end
|
51
59
|
|
52
|
-
def encode_record(record)
|
60
|
+
def encode_record(m, record)
|
53
61
|
data = []
|
54
62
|
@channels.each do |ch, v|
|
55
63
|
key, type = v
|
56
|
-
data.push('channel' => ch,
|
64
|
+
data.push('channel' => ch.to_i,
|
57
65
|
'type' => type,
|
58
66
|
'value' => record[key])
|
59
67
|
end
|
60
68
|
hash = { 'type' => 'channels',
|
69
|
+
'module' => m,
|
61
70
|
'payload' => { 'channels' => data } }
|
62
71
|
Yajl::Encoder.encode(hash)
|
63
72
|
end
|