fluent-plugin-sakuraio 0.0.7 → 0.1.0
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/CHANGELOG.md +35 -0
- data/README.md +11 -0
- data/fluent-plugin-sakuraio.gemspec +1 -1
- data/lib/fluent/plugin/in_sakuraio.rb +6 -6
- data/lib/fluent/plugin/out_sakuraio.rb +65 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dab9eca760e6bbe4e3f98bd61a23aeb36c6eb166
|
4
|
+
data.tar.gz: 5c2031207cbce00792f9fac8c8de6a039b176500
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49a9f00dfa0b299803dd2375c29b73d91e0940fc88d651f667a21afc6126447cbda327d09e84ea7612f9d0dfc8f7f5456c509e6e47f80861fb922983620abdc4
|
7
|
+
data.tar.gz: 9a0521050ddbfcbdd9aaf9fc234631a866f81727ec542cfddf0652165805567ab63c7542cd39cfa0ff3e1ed402242f489110353507a912fa22c03390f005e583
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## [v0.0.7](https://github.com/sakuraio/fluent-plugin-sakuraio/tree/v0.0.7) (2017-11-03)
|
4
|
+
[Full Changelog](https://github.com/sakuraio/fluent-plugin-sakuraio/compare/v0.0.6...v0.0.7)
|
5
|
+
|
6
|
+
**Closed issues:**
|
7
|
+
|
8
|
+
- Always invoking EM.run may be harmful [\#5](https://github.com/sakuraio/fluent-plugin-sakuraio/issues/5)
|
9
|
+
- Is mandatory url parameter? [\#4](https://github.com/sakuraio/fluent-plugin-sakuraio/issues/4)
|
10
|
+
|
11
|
+
**Merged pull requests:**
|
12
|
+
|
13
|
+
- Use secret parameter [\#3](https://github.com/sakuraio/fluent-plugin-sakuraio/pull/3) ([okkez](https://github.com/okkez))
|
14
|
+
- Fix library path [\#2](https://github.com/sakuraio/fluent-plugin-sakuraio/pull/2) ([okkez](https://github.com/okkez))
|
15
|
+
- Set Fluentd dependency [\#1](https://github.com/sakuraio/fluent-plugin-sakuraio/pull/1) ([okkez](https://github.com/okkez))
|
16
|
+
|
17
|
+
## [v0.0.6](https://github.com/sakuraio/fluent-plugin-sakuraio/tree/v0.0.6) (2017-10-31)
|
18
|
+
[Full Changelog](https://github.com/sakuraio/fluent-plugin-sakuraio/compare/v0.0.5...v0.0.6)
|
19
|
+
|
20
|
+
## [v0.0.5](https://github.com/sakuraio/fluent-plugin-sakuraio/tree/v0.0.5) (2017-10-30)
|
21
|
+
[Full Changelog](https://github.com/sakuraio/fluent-plugin-sakuraio/compare/v0.0.4...v0.0.5)
|
22
|
+
|
23
|
+
## [v0.0.4](https://github.com/sakuraio/fluent-plugin-sakuraio/tree/v0.0.4) (2017-10-30)
|
24
|
+
[Full Changelog](https://github.com/sakuraio/fluent-plugin-sakuraio/compare/v0.0.3...v0.0.4)
|
25
|
+
|
26
|
+
## [v0.0.3](https://github.com/sakuraio/fluent-plugin-sakuraio/tree/v0.0.3) (2017-10-30)
|
27
|
+
[Full Changelog](https://github.com/sakuraio/fluent-plugin-sakuraio/compare/v0.0.2...v0.0.3)
|
28
|
+
|
29
|
+
## [v0.0.2](https://github.com/sakuraio/fluent-plugin-sakuraio/tree/v0.0.2) (2017-10-30)
|
30
|
+
[Full Changelog](https://github.com/sakuraio/fluent-plugin-sakuraio/compare/v0.0.1...v0.0.2)
|
31
|
+
|
32
|
+
## [v0.0.1](https://github.com/sakuraio/fluent-plugin-sakuraio/tree/v0.0.1) (2017-10-30)
|
33
|
+
|
34
|
+
|
35
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/README.md
CHANGED
@@ -37,6 +37,17 @@ gem install 'fluent-plugin-sakuraio'
|
|
37
37
|
|
38
38
|
The details of sakura.io message spec: https://sakura.io/docs/pages/platform-specification/message.html
|
39
39
|
|
40
|
+
## Output Configuration
|
41
|
+
|
42
|
+
```
|
43
|
+
<match **>
|
44
|
+
@type sakuraio
|
45
|
+
url wss://api.sakura.io/ws/v1/xxxxxxxxxxxxxxxxxxxxxxx
|
46
|
+
modules ["uXXXXXXXXXXX"] # array of modules
|
47
|
+
channels {"0": ["key", "i"]} # hash of channels {"channel number": ["key in record", "data type"]}
|
48
|
+
</match>
|
49
|
+
```
|
50
|
+
|
40
51
|
## License
|
41
52
|
|
42
53
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -14,6 +14,7 @@ module Fluent::Plugin
|
|
14
14
|
def configure(conf)
|
15
15
|
super
|
16
16
|
|
17
|
+
@client = Faye::WebSocket::Client.new(@url)
|
17
18
|
@time_parser = Fluent::TimeParser.new(nil)
|
18
19
|
end
|
19
20
|
|
@@ -39,12 +40,11 @@ module Fluent::Plugin
|
|
39
40
|
|
40
41
|
def run
|
41
42
|
EM.next_tick do
|
42
|
-
client
|
43
|
-
client.on :open do
|
43
|
+
@client.on :open do
|
44
44
|
log.info "sakuraio: starting websocket connection for #{@url}."
|
45
45
|
end
|
46
46
|
|
47
|
-
client.on :message do |event|
|
47
|
+
@client.on :message do |event|
|
48
48
|
log.debug "sakuraio: received message #{event.data}"
|
49
49
|
records = parse(event.data)
|
50
50
|
unless records.empty?
|
@@ -54,12 +54,12 @@ module Fluent::Plugin
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
client.on :error do |event|
|
57
|
+
@client.on :error do |event|
|
58
58
|
log.warn "sakuraio: #{event.message}"
|
59
59
|
end
|
60
60
|
|
61
|
-
client.on :close do
|
62
|
-
client = nil
|
61
|
+
@client.on :close do
|
62
|
+
@client = nil
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'fluent/plugin/output'
|
2
|
+
require 'yajl'
|
3
|
+
require 'faye/websocket'
|
4
|
+
|
5
|
+
module Fluent::Plugin
|
6
|
+
class SakuraIOOutput < Output
|
7
|
+
Fluent::Plugin.register_output('sakuraio', self)
|
8
|
+
|
9
|
+
config_param :url, :string, secret: true
|
10
|
+
config_param :modules, :array, value_type: :string, secret: true
|
11
|
+
# channels {"channel_number": ["key", "type"]}
|
12
|
+
config_param :channels, :hash
|
13
|
+
|
14
|
+
def configure(conf)
|
15
|
+
super
|
16
|
+
|
17
|
+
@client = Faye::WebSocket::Client.new(@url)
|
18
|
+
ensure_reactor_running
|
19
|
+
thread_create(:out_sakuraio, &method(:run))
|
20
|
+
end
|
21
|
+
|
22
|
+
def ensure_reactor_running
|
23
|
+
return if EM.reactor_running?
|
24
|
+
thread_create(:out_sakuraio_reactor) do
|
25
|
+
EM.run
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def run
|
30
|
+
EM.next_tick do
|
31
|
+
@client.on :open do
|
32
|
+
log.info "sakuraio: starting websocket connection for #{@url}."
|
33
|
+
end
|
34
|
+
|
35
|
+
@client.on :error do |event|
|
36
|
+
log.warn "sakuraio: #{event.message}"
|
37
|
+
end
|
38
|
+
|
39
|
+
@client.on :close do
|
40
|
+
@client = nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def process(_tag, es)
|
46
|
+
es.each do |_time, record|
|
47
|
+
log.debug "sakuraio: process record #{record}"
|
48
|
+
@client.send(encode_record(record))
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def encode_record(record)
|
53
|
+
data = []
|
54
|
+
@channels.each do |ch, v|
|
55
|
+
key, type = v
|
56
|
+
data.push('channel' => ch,
|
57
|
+
'type' => type,
|
58
|
+
'value' => record[key])
|
59
|
+
end
|
60
|
+
hash = { 'type' => 'channels',
|
61
|
+
'payload' => { 'channels' => data } }
|
62
|
+
Yajl::Encoder.encode(hash)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-sakuraio
|
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
|
- Yuya Kusakabe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|
@@ -151,12 +151,14 @@ extra_rdoc_files: []
|
|
151
151
|
files:
|
152
152
|
- ".gitignore"
|
153
153
|
- ".travis.yml"
|
154
|
+
- CHANGELOG.md
|
154
155
|
- Gemfile
|
155
156
|
- LICENSE.txt
|
156
157
|
- README.md
|
157
158
|
- Rakefile
|
158
159
|
- fluent-plugin-sakuraio.gemspec
|
159
160
|
- lib/fluent/plugin/in_sakuraio.rb
|
161
|
+
- lib/fluent/plugin/out_sakuraio.rb
|
160
162
|
homepage: https://github.com/sakuraio/fluent-plugin-sakuraio
|
161
163
|
licenses:
|
162
164
|
- MIT
|