fluent-plugin-chatwork 1.0.1 → 2.0.0.beta1
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-chatwork.gemspec +2 -2
- data/lib/fluent/plugin/out_chatwork.rb +34 -4
- data/spec/lib/fluent/plugin/chatwork_spec.rb +30 -4
- data/spec/spec_helper.rb +1 -0
- metadata +13 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19df334b710b279bba1f7d0116f51de3dd3c494e
|
4
|
+
data.tar.gz: 7ce33435ce3ea73cac806992a5696c4e5f5aa23b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccd4c7ab415214e3d2f63cfaa1b9691ec27890d93fc04e78344439db0ae2ed570dd4d89ea97249300829d84bbefec396680fe8c00d1cdc124f5646016dd6e888
|
7
|
+
data.tar.gz: 879297e60af8b5b3ea5d0c90f24a58a9a4f3ad39339766fa755c1122f936d6ff5c482ef67fab268e8c2bddcea8c9094b6208bb09a92d29326203badca9a90a34
|
@@ -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-chatwork"
|
7
|
-
spec.version = "
|
7
|
+
spec.version = "2.0.0.beta1"
|
8
8
|
spec.authors = ["sue445"]
|
9
9
|
spec.email = ["sue445@sue445.net"]
|
10
10
|
spec.summary = %q{fluentd output plugin for post to chatwork}
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_dependency "fluentd"
|
20
|
+
spec.add_dependency "fluentd", [">= 0.14.15", "< 2"]
|
21
21
|
spec.add_dependency "chatwork", ">= 0.4.0"
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler"
|
@@ -1,15 +1,27 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
require "chatwork"
|
3
|
+
require "fluent/plugin/output"
|
3
4
|
|
4
|
-
module Fluent
|
5
|
-
class ChatworkOutput <
|
5
|
+
module Fluent::Plugin
|
6
|
+
class ChatworkOutput < Output
|
6
7
|
# First, register the plugin. NAME is the name of this plugin
|
7
8
|
# and identifies the plugin in the configuration file.
|
8
9
|
Fluent::Plugin.register_output('chatwork', self)
|
9
10
|
|
11
|
+
helpers :compat_parameters
|
12
|
+
|
13
|
+
DEFAULT_BUFFER_TYPE = "memory"
|
14
|
+
|
10
15
|
config_param :api_token, :string
|
11
16
|
config_param :room_id , :string
|
12
17
|
config_param :message , :string
|
18
|
+
# Switch non-buffered/buffered plugin
|
19
|
+
config_param :buffered, :bool, default: false
|
20
|
+
|
21
|
+
config_section :buffer do
|
22
|
+
config_set_default :@type, DEFAULT_BUFFER_TYPE
|
23
|
+
config_set_default :chunk_keys, ['tag']
|
24
|
+
end
|
13
25
|
|
14
26
|
# This method is called before starting.
|
15
27
|
def configure(conf)
|
@@ -26,18 +38,36 @@ module Fluent
|
|
26
38
|
super
|
27
39
|
end
|
28
40
|
|
41
|
+
def prefer_buffered_processing
|
42
|
+
@buffered
|
43
|
+
end
|
44
|
+
|
45
|
+
def formatted_to_msgpack_binary?
|
46
|
+
true
|
47
|
+
end
|
48
|
+
|
49
|
+
def format(tag, time, record)
|
50
|
+
[time, record].to_msgpack
|
51
|
+
end
|
52
|
+
|
29
53
|
# This method is called when an event reaches Fluentd.
|
30
54
|
# 'es' is a Fluent::EventStream object that includes multiple events.
|
31
55
|
# You can use 'es.each {|time,record| ... }' to retrieve events.
|
32
56
|
# 'chain' is an object that manages transactions. Call 'chain.next' at
|
33
57
|
# appropriate points and rollback if it raises an exception.
|
34
|
-
def
|
35
|
-
chain.next
|
58
|
+
def process(tag, es)
|
36
59
|
es.each {|time,record|
|
37
60
|
post_message(time: time, record: record, tag: tag)
|
38
61
|
}
|
39
62
|
end
|
40
63
|
|
64
|
+
def write(chunk)
|
65
|
+
tag = chunk.metadata.tag
|
66
|
+
chunk.msgpack_each {|time, record|
|
67
|
+
post_message(time: time, record: record, tag: tag)
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
41
71
|
def post_message(args={})
|
42
72
|
body = generate_message(args)
|
43
73
|
ChatWork.api_key = @api_token
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
describe Fluent::ChatworkOutput do
|
3
|
+
describe Fluent::Plugin::ChatworkOutput do
|
4
4
|
before do
|
5
5
|
Fluent::Test.setup
|
6
6
|
end
|
7
7
|
|
8
|
-
let(:driver) { Fluent::Test::
|
8
|
+
let(:driver) { Fluent::Test::Driver::Output.new(Fluent::Plugin::ChatworkOutput).configure(config) }
|
9
9
|
let(:instance) { driver.instance }
|
10
10
|
|
11
11
|
let(:config) do
|
@@ -28,6 +28,10 @@ describe Fluent::ChatworkOutput do
|
|
28
28
|
it "should get message" do
|
29
29
|
expect( instance.message ).to eq "some message"
|
30
30
|
end
|
31
|
+
|
32
|
+
it "should get buffered" do
|
33
|
+
expect( instance.buffered ).to be_falsy
|
34
|
+
end
|
31
35
|
end
|
32
36
|
|
33
37
|
describe "#emit" do
|
@@ -38,8 +42,30 @@ describe Fluent::ChatworkOutput do
|
|
38
42
|
end
|
39
43
|
|
40
44
|
it "should be called" do
|
41
|
-
driver.
|
42
|
-
expect(driver.
|
45
|
+
driver.run(default_tag: "test.metrics") { driver.feed(record) }
|
46
|
+
expect(driver.events).not_to be_nil
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "buffered #emit" do
|
51
|
+
let(:record){ {} }
|
52
|
+
|
53
|
+
let(:config) do
|
54
|
+
%[
|
55
|
+
api_token xxxxxxxxxxxxxxxxxxxx
|
56
|
+
room_id 1234567890
|
57
|
+
message some message
|
58
|
+
buffered true
|
59
|
+
]
|
60
|
+
end
|
61
|
+
|
62
|
+
before do
|
63
|
+
allow(instance).to receive(:post_message)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should be called" do
|
67
|
+
driver.run(default_tag: "test.metrics") { driver.feed(record) }
|
68
|
+
expect(driver.events).not_to be_nil
|
43
69
|
end
|
44
70
|
end
|
45
71
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-chatwork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sue445
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-12 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: chatwork
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,12 +178,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
172
178
|
version: '0'
|
173
179
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
180
|
requirements:
|
175
|
-
- - "
|
181
|
+
- - ">"
|
176
182
|
- !ruby/object:Gem::Version
|
177
|
-
version:
|
183
|
+
version: 1.3.1
|
178
184
|
requirements: []
|
179
185
|
rubyforge_project:
|
180
|
-
rubygems_version: 2.
|
186
|
+
rubygems_version: 2.5.2
|
181
187
|
signing_key:
|
182
188
|
specification_version: 4
|
183
189
|
summary: fluentd output plugin for post to chatwork
|