fluent-plugin-gcloud-pubsub-custom 0.4.1 → 0.4.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: b6a3dc4854e4b3d760150f6ba6e46513fd432d82
|
4
|
+
data.tar.gz: e79d3538b84e949c8754c4c40f429af5ccfb9b42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 611d5fc134b67c6f51740beeab19fa2ee0fe1a001399fb3cbddb64b71a0187b5bcab8000dac1a007d0758de0d9923f838b424a8e95098e4c95783d6a192141e5
|
7
|
+
data.tar.gz: 8cd2edd9f32f283ba06686a102ee66af5a7c9d86811a86fe38491d336d431f2c85fc1caa21b387cc9328678897c380b1a00d7fca9610b2d412bf5c97542beb22
|
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.4.
|
10
|
+
gem.version = "0.4.2"
|
11
11
|
gem.authors = ["Yoshihiro MIYAI"]
|
12
12
|
gem.email = "msparrow17@gmail.com"
|
13
13
|
gem.has_rdoc = false
|
@@ -18,6 +18,7 @@ Gem::Specification.new do |gem|
|
|
18
18
|
|
19
19
|
gem.add_runtime_dependency "fluentd", [">= 0.10.58", "< 2"]
|
20
20
|
gem.add_runtime_dependency "google-cloud-pubsub", "~> 0.22.0"
|
21
|
+
gem.add_runtime_dependency "retryable", "~> 2.0"
|
21
22
|
|
22
23
|
gem.add_development_dependency "bundler"
|
23
24
|
gem.add_development_dependency "rake"
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'google/cloud/pubsub'
|
2
|
+
require 'retryable'
|
2
3
|
|
3
4
|
module Fluent
|
4
5
|
module GcloudPubSub
|
@@ -8,11 +9,15 @@ module Fluent
|
|
8
9
|
end
|
9
10
|
|
10
11
|
class Publisher
|
11
|
-
|
12
|
-
|
12
|
+
RETRY_COUNT = 5
|
13
|
+
RETRYABLE_ERRORS = [Google::Cloud::UnavailableError, Google::Cloud::DeadlineExceededError, Google::Cloud::InternalError]
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
def initialize(project, key, topic_name, autocreate_topic)
|
16
|
+
Retryable.retryable(tries: RETRY_COUNT, on: RETRYABLE_ERRORS) do
|
17
|
+
pubsub = Google::Cloud::Pubsub.new project: project, keyfile: key
|
18
|
+
@client = pubsub.topic topic_name, autocreate: autocreate_topic
|
19
|
+
end
|
20
|
+
raise Error.new "topic:#{topic_name} does not exist." if @client.nil?
|
16
21
|
end
|
17
22
|
|
18
23
|
def publish(messages)
|
@@ -27,11 +32,16 @@ module Fluent
|
|
27
32
|
end
|
28
33
|
|
29
34
|
class Subscriber
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
+
RETRY_COUNT = 5
|
36
|
+
RETRYABLE_ERRORS = [Google::Cloud::UnavailableError, Google::Cloud::DeadlineExceededError, Google::Cloud::InternalError]
|
37
|
+
|
38
|
+
def initialize(project, key, topic_name, subscription_name)
|
39
|
+
Retryable.retryable(tries: RETRY_COUNT, on: RETRYABLE_ERRORS) do
|
40
|
+
pubsub = Google::Cloud::Pubsub.new project: project, keyfile: key
|
41
|
+
topic = pubsub.topic topic_name
|
42
|
+
@client = topic.subscription subscription_name
|
43
|
+
end
|
44
|
+
raise Error.new "subscription:#{subscription_name} does not exist." if @client.nil?
|
35
45
|
end
|
36
46
|
|
37
47
|
def pull(immediate, max)
|
@@ -87,6 +87,45 @@ class GcloudPubSubInputTest < Test::Unit::TestCase
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
+
sub_test_case 'start' do
|
91
|
+
setup do
|
92
|
+
@topic_mock = mock!
|
93
|
+
@pubsub_mock = mock!.topic('topic-test').at_least(1) { @topic_mock }
|
94
|
+
stub(Google::Cloud::Pubsub).new { @pubsub_mock }
|
95
|
+
end
|
96
|
+
|
97
|
+
test '40x error occurred on connecting to Pub/Sub' do
|
98
|
+
@topic_mock.subscription('subscription-test').once do
|
99
|
+
raise Google::Cloud::NotFoundError.new('TEST')
|
100
|
+
end
|
101
|
+
|
102
|
+
d = create_driver
|
103
|
+
assert_raise Google::Cloud::NotFoundError do
|
104
|
+
d.run {}
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
test '50x error occurred on connecting to Pub/Sub' do
|
109
|
+
@topic_mock.subscription('subscription-test').times(5) do
|
110
|
+
raise Google::Cloud::UnavailableError.new('TEST')
|
111
|
+
end
|
112
|
+
|
113
|
+
d = create_driver
|
114
|
+
assert_raise Google::Cloud::UnavailableError do
|
115
|
+
d.run {}
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
test 'subscription is nil' do
|
120
|
+
@topic_mock.subscription('subscription-test').once { nil }
|
121
|
+
|
122
|
+
d = create_driver
|
123
|
+
assert_raise Fluent::GcloudPubSub::Error do
|
124
|
+
d.run {}
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
90
129
|
sub_test_case 'emit' do
|
91
130
|
class DummyMsgData
|
92
131
|
def data
|
@@ -72,6 +72,40 @@ class GcloudPubSubOutputTest < Test::Unit::TestCase
|
|
72
72
|
@pubsub_mock.topic("topic-test", autocreate: true).once { @publisher }
|
73
73
|
d.run
|
74
74
|
end
|
75
|
+
|
76
|
+
test '40x error occurred on connecting to Pub/Sub' do
|
77
|
+
d = create_driver
|
78
|
+
|
79
|
+
@pubsub_mock.topic('topic-test', autocreate: false).once do
|
80
|
+
raise Google::Cloud::NotFoundError.new('TEST')
|
81
|
+
end
|
82
|
+
|
83
|
+
assert_raise Google::Cloud::NotFoundError do
|
84
|
+
d.run {}
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
test '50x error occurred on connecting to Pub/Sub' do
|
89
|
+
d = create_driver
|
90
|
+
|
91
|
+
@pubsub_mock.topic('topic-test', autocreate: false).times(5) do
|
92
|
+
raise Google::Cloud::UnavailableError.new('TEST')
|
93
|
+
end
|
94
|
+
|
95
|
+
assert_raise Google::Cloud::UnavailableError do
|
96
|
+
d.run {}
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
test 'topic is nil' do
|
101
|
+
d = create_driver
|
102
|
+
|
103
|
+
@pubsub_mock.topic('topic-test', autocreate: false).once { nil }
|
104
|
+
|
105
|
+
assert_raise Fluent::GcloudPubSub::Error do
|
106
|
+
d.run {}
|
107
|
+
end
|
108
|
+
end
|
75
109
|
end
|
76
110
|
|
77
111
|
sub_test_case 'publish' 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.
|
4
|
+
version: 0.4.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-02-
|
11
|
+
date: 2017-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -44,6 +44,20 @@ dependencies:
|
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 0.22.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'
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: bundler
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|