fluent-plugin-gcloud-pubsub-custom 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/fluent-plugin-gcloud-pubsub-custom.gemspec +2 -2
- data/lib/fluent/plugin/gcloud_pubsub/client.rb +3 -3
- data/lib/fluent/plugin/in_gcloud_pubsub.rb +6 -2
- data/test/plugin/test_in_gcloud_pubsub.rb +22 -2
- data/test/plugin/test_out_gcloud_pubsub.rb +2 -4
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6537f709d3f3e8849ae455fad4ee15a5f8b36d36
|
4
|
+
data.tar.gz: 72ac72b492b01d4ac1301837f9faeaa185689f72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21dfe776b5de4edfedc3cd71c47c050934db1b09ddb05f43a6d7c2fff0f7586e450bb669d7b5c9e5b7b5569dec176b6d1fed05f0aee12f3f01091c697f6cfe88
|
7
|
+
data.tar.gz: 0c388a5d3eaf2edd941c81ba76676fc21ca9950b12c3fd6229f8e6981d6affc68ca33dc26d76a151fa4e7e752fbac33ff48cb0b3843b04542b2dd90605ac52d3
|
data/CHANGELOG.md
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |gem|
|
|
7
7
|
gem.license = "MIT"
|
8
8
|
gem.homepage = "https://github.com/mia-0032/fluent-plugin-gcloud-pubsub-custom"
|
9
9
|
gem.summary = gem.description
|
10
|
-
gem.version = "0.
|
10
|
+
gem.version = "0.3.0"
|
11
11
|
gem.authors = ["Yoshihiro MIYAI"]
|
12
12
|
gem.email = "msparrow17@gmail.com"
|
13
13
|
gem.has_rdoc = false
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.require_paths = ['lib']
|
18
18
|
|
19
19
|
gem.add_runtime_dependency "fluentd", [">= 0.10.58", "< 2"]
|
20
|
-
gem.add_runtime_dependency "google-cloud-pubsub", "~> 0.
|
20
|
+
gem.add_runtime_dependency "google-cloud-pubsub", "~> 0.21.0"
|
21
21
|
|
22
22
|
gem.add_development_dependency "bundler"
|
23
23
|
gem.add_development_dependency "rake"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'google/cloud'
|
1
|
+
require 'google/cloud/pubsub'
|
2
2
|
|
3
3
|
module Fluent
|
4
4
|
module GcloudPubSub
|
@@ -6,7 +6,7 @@ module Fluent
|
|
6
6
|
|
7
7
|
class Publisher
|
8
8
|
def initialize(project, key, topic, autocreate_topic)
|
9
|
-
pubsub =
|
9
|
+
pubsub = Google::Cloud::Pubsub.new project: project, keyfile: key
|
10
10
|
|
11
11
|
@client = pubsub.topic topic, autocreate: autocreate_topic
|
12
12
|
raise Fluent::GcloudPubSub::Error.new "topic:#{topic} does not exist." if @client.nil?
|
@@ -23,7 +23,7 @@ module Fluent
|
|
23
23
|
|
24
24
|
class Subscriber
|
25
25
|
def initialize(project, key, topic, subscription)
|
26
|
-
pubsub =
|
26
|
+
pubsub = Google::Cloud::Pubsub.new project: project, keyfile: key
|
27
27
|
topic = pubsub.topic topic
|
28
28
|
@client = topic.subscription subscription
|
29
29
|
raise Fluent::GcloudPubSub::Error.new "subscription:#{subscription} does not exist." if @client.nil?
|
@@ -18,6 +18,7 @@ module Fluent
|
|
18
18
|
config_param :pull_interval, :float, default: 5.0
|
19
19
|
config_param :max_messages, :integer, default: 100
|
20
20
|
config_param :return_immediately, :bool, default: true
|
21
|
+
config_param :pull_threads, :integer, default: 1
|
21
22
|
config_param :format, :string, default: 'json'
|
22
23
|
# for HTTP RPC
|
23
24
|
config_param :enable_rpc, :bool, default: false
|
@@ -94,7 +95,10 @@ module Fluent
|
|
94
95
|
log.debug "connected subscription:#{@subscription} in project #{@project}"
|
95
96
|
|
96
97
|
@stop_subscribing = false
|
97
|
-
@
|
98
|
+
@subscribe_threads = []
|
99
|
+
@pull_threads.times do
|
100
|
+
@subscribe_threads.push Thread.new(&method(:subscribe))
|
101
|
+
end
|
98
102
|
end
|
99
103
|
|
100
104
|
def shutdown
|
@@ -108,7 +112,7 @@ module Fluent
|
|
108
112
|
@rpc_thread = nil
|
109
113
|
end
|
110
114
|
@stop_subscribing = true
|
111
|
-
@
|
115
|
+
@subscribe_threads.each(&:join)
|
112
116
|
end
|
113
117
|
|
114
118
|
def stop_pull
|
@@ -40,6 +40,7 @@ class GcloudPubSubInputTest < Test::Unit::TestCase
|
|
40
40
|
max_messages 1000
|
41
41
|
return_immediately true
|
42
42
|
pull_interval 2
|
43
|
+
pull_threads 3
|
43
44
|
format ltsv
|
44
45
|
enable_rpc true
|
45
46
|
rpc_bind 127.0.0.1
|
@@ -54,6 +55,7 @@ class GcloudPubSubInputTest < Test::Unit::TestCase
|
|
54
55
|
assert_equal(2.0, d.instance.pull_interval)
|
55
56
|
assert_equal(1000, d.instance.max_messages)
|
56
57
|
assert_equal(true, d.instance.return_immediately)
|
58
|
+
assert_equal(3, d.instance.pull_threads)
|
57
59
|
assert_equal('ltsv', d.instance.format)
|
58
60
|
assert_equal(true, d.instance.enable_rpc)
|
59
61
|
assert_equal('127.0.0.1', d.instance.rpc_bind)
|
@@ -65,6 +67,7 @@ class GcloudPubSubInputTest < Test::Unit::TestCase
|
|
65
67
|
assert_equal(5.0, d.instance.pull_interval)
|
66
68
|
assert_equal(100, d.instance.max_messages)
|
67
69
|
assert_equal(true, d.instance.return_immediately)
|
70
|
+
assert_equal(1, d.instance.pull_threads)
|
68
71
|
assert_equal('json', d.instance.format)
|
69
72
|
assert_equal(false, d.instance.enable_rpc)
|
70
73
|
assert_equal('0.0.0.0', d.instance.rpc_bind)
|
@@ -88,8 +91,7 @@ class GcloudPubSubInputTest < Test::Unit::TestCase
|
|
88
91
|
@subscriber = mock!
|
89
92
|
@topic_mock = mock!.subscription('subscription-test') { @subscriber }
|
90
93
|
@pubsub_mock = mock!.topic('topic-test') { @topic_mock }
|
91
|
-
|
92
|
-
stub(Google::Cloud).new { @gcloud_mock }
|
94
|
+
stub(Google::Cloud::Pubsub).new { @pubsub_mock }
|
93
95
|
end
|
94
96
|
|
95
97
|
test 'empty' do
|
@@ -122,6 +124,24 @@ class GcloudPubSubInputTest < Test::Unit::TestCase
|
|
122
124
|
end
|
123
125
|
end
|
124
126
|
|
127
|
+
test 'multithread' do
|
128
|
+
messages = Array.new(1, DummyMessage.new)
|
129
|
+
@subscriber.pull(immediate: true, max: 100).twice { messages }
|
130
|
+
@subscriber.acknowledge(messages).twice
|
131
|
+
|
132
|
+
d = create_driver("#{CONFIG}\npull_threads 2")
|
133
|
+
d.run {
|
134
|
+
# d.run sleeps 0.5 sec
|
135
|
+
}
|
136
|
+
emits = d.emits
|
137
|
+
|
138
|
+
assert_equal(2, emits.length)
|
139
|
+
emits.each do |tag, time, record|
|
140
|
+
assert_equal("test", tag)
|
141
|
+
assert_equal({"foo" => "bar"}, record)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
125
145
|
test 'invalid messages' do
|
126
146
|
class DummyInvalidMsgData
|
127
147
|
def data
|
@@ -58,8 +58,7 @@ class GcloudPubSubOutputTest < Test::Unit::TestCase
|
|
58
58
|
setup do
|
59
59
|
@publisher = mock!
|
60
60
|
@pubsub_mock = mock!
|
61
|
-
|
62
|
-
stub(Google::Cloud).new { @gcloud_mock }
|
61
|
+
stub(Google::Cloud::Pubsub).new { @pubsub_mock }
|
63
62
|
end
|
64
63
|
|
65
64
|
test '"autocreate_topic" is enabled' do
|
@@ -79,8 +78,7 @@ class GcloudPubSubOutputTest < Test::Unit::TestCase
|
|
79
78
|
setup do
|
80
79
|
@publisher = mock!
|
81
80
|
@pubsub_mock = mock!.topic(anything, anything) { @publisher }
|
82
|
-
|
83
|
-
stub(Google::Cloud).new { @gcloud_mock }
|
81
|
+
stub(Google::Cloud::Pubsub).new { @pubsub_mock }
|
84
82
|
end
|
85
83
|
|
86
84
|
setup do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-gcloud-pubsub-custom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshihiro MIYAI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -36,14 +36,14 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.
|
39
|
+
version: 0.21.0
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.
|
46
|
+
version: 0.21.0
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|