fluent-plugin-gcloud-pubsub-custom 1.0.1 → 1.0.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68f6350d90177c7ec295da11f19e9a65ef5742e8
|
4
|
+
data.tar.gz: d4114cf5858f6391db2369c70a51ebbdaf3aa0a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22d5d1460341bf37c49c05c25eed92c5bf859944f5d7ebbfb4e3621f94cb0deb597eebc1400a601dfd48e63a5327b1a8d1f42114d484e240e6fcd9195fa04b36
|
7
|
+
data.tar.gz: f2bba857a997391318244eaee64713aa3dd9718779c19a43277db9723377b90f45b98d6350f525ea1e363880ae9be5509f782f41046f3f65c36941de8a4630d6
|
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 = "1.0.
|
10
|
+
gem.version = "1.0.2"
|
11
11
|
gem.authors = ["Yoshihiro MIYAI"]
|
12
12
|
gem.email = "msparrow17@gmail.com"
|
13
13
|
gem.has_rdoc = false
|
@@ -17,8 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.require_paths = ['lib']
|
18
18
|
|
19
19
|
gem.add_runtime_dependency "fluentd", [">= 0.14.15", "< 2"]
|
20
|
-
gem.add_runtime_dependency "google-cloud-pubsub", "~> 0.
|
21
|
-
gem.add_runtime_dependency "retryable", "~> 2.0"
|
20
|
+
gem.add_runtime_dependency "google-cloud-pubsub", "~> 0.27.0"
|
22
21
|
|
23
22
|
gem.add_development_dependency "bundler"
|
24
23
|
gem.add_development_dependency "rake"
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'google/cloud/pubsub'
|
2
|
-
require 'retryable'
|
3
2
|
|
4
3
|
module Fluent
|
5
4
|
module GcloudPubSub
|
@@ -9,15 +8,16 @@ module Fluent
|
|
9
8
|
end
|
10
9
|
|
11
10
|
class Publisher
|
12
|
-
RETRY_COUNT = 5
|
13
|
-
RETRYABLE_ERRORS = [Google::Cloud::UnavailableError, Google::Cloud::DeadlineExceededError, Google::Cloud::InternalError]
|
14
|
-
|
15
11
|
def initialize(project, key, topic_name, autocreate_topic)
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
pubsub = Google::Cloud::Pubsub.new project: project, keyfile: key
|
13
|
+
@client = pubsub.topic topic_name
|
14
|
+
if @client.nil?
|
15
|
+
if autocreate_topic
|
16
|
+
@client = pubsub.create_topic topic_name
|
17
|
+
else
|
18
|
+
raise Error.new "topic:#{topic_name} does not exist."
|
19
|
+
end
|
19
20
|
end
|
20
|
-
raise Error.new "topic:#{topic_name} does not exist." if @client.nil?
|
21
21
|
end
|
22
22
|
|
23
23
|
def publish(messages)
|
@@ -32,15 +32,10 @@ module Fluent
|
|
32
32
|
end
|
33
33
|
|
34
34
|
class Subscriber
|
35
|
-
RETRY_COUNT = 5
|
36
|
-
RETRYABLE_ERRORS = [Google::Cloud::UnavailableError, Google::Cloud::DeadlineExceededError, Google::Cloud::InternalError]
|
37
|
-
|
38
35
|
def initialize(project, key, topic_name, subscription_name)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
@client = topic.subscription subscription_name
|
43
|
-
end
|
36
|
+
pubsub = Google::Cloud::Pubsub.new project: project, keyfile: key
|
37
|
+
topic = pubsub.topic topic_name
|
38
|
+
@client = topic.subscription subscription_name
|
44
39
|
raise Error.new "subscription:#{subscription_name} does not exist." if @client.nil?
|
45
40
|
end
|
46
41
|
|
@@ -108,7 +108,7 @@ class GcloudPubSubInputTest < Test::Unit::TestCase
|
|
108
108
|
end
|
109
109
|
|
110
110
|
test '50x error occurred on connecting to Pub/Sub' do
|
111
|
-
@topic_mock.subscription('subscription-test').
|
111
|
+
@topic_mock.subscription('subscription-test').once do
|
112
112
|
raise Google::Cloud::UnavailableError.new('TEST')
|
113
113
|
end
|
114
114
|
|
@@ -177,13 +177,13 @@ class GcloudPubSubInputTest < Test::Unit::TestCase
|
|
177
177
|
test 'simple' do
|
178
178
|
messages = Array.new(1, DummyMessage.new)
|
179
179
|
@subscriber.pull(immediate: true, max: 100).at_least(1) { messages }
|
180
|
-
@subscriber.acknowledge(messages).
|
180
|
+
@subscriber.acknowledge(messages).at_least(1)
|
181
181
|
|
182
182
|
d = create_driver
|
183
183
|
d.run(expect_emits: 1, timeout: 3)
|
184
184
|
emits = d.events
|
185
185
|
|
186
|
-
|
186
|
+
assert(1 <= emits.length)
|
187
187
|
emits.each do |tag, time, record|
|
188
188
|
assert_equal("test", tag)
|
189
189
|
assert_equal({"foo" => "bar"}, record)
|
@@ -213,13 +213,13 @@ class GcloudPubSubInputTest < Test::Unit::TestCase
|
|
213
213
|
DummyMessage.new
|
214
214
|
]
|
215
215
|
@subscriber.pull(immediate: true, max: 100).at_least(1) { messages }
|
216
|
-
@subscriber.acknowledge(messages).
|
216
|
+
@subscriber.acknowledge(messages).at_least(1)
|
217
217
|
|
218
218
|
d = create_driver("#{CONFIG}\ntag_key test_tag_key")
|
219
219
|
d.run(expect_emits: 1, timeout: 3)
|
220
220
|
emits = d.events
|
221
221
|
|
222
|
-
|
222
|
+
assert(3 <= emits.length)
|
223
223
|
# test tag
|
224
224
|
assert_equal("tag1", emits[0][0])
|
225
225
|
assert_equal("tag2", emits[1][0])
|
@@ -277,7 +277,7 @@ class GcloudPubSubInputTest < Test::Unit::TestCase
|
|
277
277
|
test 'retry if raised RetryableError on acknowledge' do
|
278
278
|
messages = Array.new(1, DummyMessage.new)
|
279
279
|
@subscriber.pull(immediate: true, max: 100).at_least(2) { messages }
|
280
|
-
@subscriber.acknowledge(messages).
|
280
|
+
@subscriber.acknowledge(messages).at_least(2) { raise Google::Cloud::UnavailableError.new('TEST') }
|
281
281
|
|
282
282
|
d = create_driver("#{CONFIG}\npull_interval 0.5")
|
283
283
|
d.run(expect_emits: 2, timeout: 3)
|
@@ -75,14 +75,15 @@ class GcloudPubSubOutputTest < Test::Unit::TestCase
|
|
75
75
|
autocreate_topic true
|
76
76
|
])
|
77
77
|
|
78
|
-
@pubsub_mock.topic("topic-test"
|
78
|
+
@pubsub_mock.topic("topic-test").once { nil }
|
79
|
+
@pubsub_mock.create_topic("topic-test").once { @publisher }
|
79
80
|
d.run
|
80
81
|
end
|
81
82
|
|
82
83
|
test '40x error occurred on connecting to Pub/Sub' do
|
83
84
|
d = create_driver
|
84
85
|
|
85
|
-
@pubsub_mock.topic('topic-test'
|
86
|
+
@pubsub_mock.topic('topic-test').once do
|
86
87
|
raise Google::Cloud::NotFoundError.new('TEST')
|
87
88
|
end
|
88
89
|
|
@@ -94,7 +95,7 @@ class GcloudPubSubOutputTest < Test::Unit::TestCase
|
|
94
95
|
test '50x error occurred on connecting to Pub/Sub' do
|
95
96
|
d = create_driver
|
96
97
|
|
97
|
-
@pubsub_mock.topic('topic-test'
|
98
|
+
@pubsub_mock.topic('topic-test').once do
|
98
99
|
raise Google::Cloud::UnavailableError.new('TEST')
|
99
100
|
end
|
100
101
|
|
@@ -106,7 +107,7 @@ class GcloudPubSubOutputTest < Test::Unit::TestCase
|
|
106
107
|
test 'topic is nil' do
|
107
108
|
d = create_driver
|
108
109
|
|
109
|
-
@pubsub_mock.topic('topic-test'
|
110
|
+
@pubsub_mock.topic('topic-test').once { nil }
|
110
111
|
|
111
112
|
assert_raise Fluent::GcloudPubSub::Error do
|
112
113
|
d.run {}
|
@@ -117,7 +118,7 @@ class GcloudPubSubOutputTest < Test::Unit::TestCase
|
|
117
118
|
sub_test_case 'publish' do
|
118
119
|
setup do
|
119
120
|
@publisher = mock!
|
120
|
-
@pubsub_mock = mock!.topic(anything
|
121
|
+
@pubsub_mock = mock!.topic(anything) { @publisher }
|
121
122
|
stub(Google::Cloud::Pubsub).new { @pubsub_mock }
|
122
123
|
end
|
123
124
|
|
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: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshihiro MIYAI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -36,28 +36,14 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.
|
39
|
+
version: 0.27.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.
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: retryable
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - "~>"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '2.0'
|
54
|
-
type: :runtime
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '2.0'
|
46
|
+
version: 0.27.0
|
61
47
|
- !ruby/object:Gem::Dependency
|
62
48
|
name: bundler
|
63
49
|
requirement: !ruby/object:Gem::Requirement
|