fluent-plugin-gcloud-pubsub-custom 0.3.4.pre → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -7
- data/CHANGELOG.md +9 -0
- data/README.md +8 -3
- data/fluent-plugin-gcloud-pubsub-custom.gemspec +1 -1
- data/lib/fluent/plugin/gcloud_pubsub/client.rb +3 -1
- data/lib/fluent/plugin/in_gcloud_pubsub.rb +10 -1
- data/test/plugin/test_in_gcloud_pubsub.rb +37 -12
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dea78067ca4b8f4a2859ed280ad3e577fee82767
|
4
|
+
data.tar.gz: 3aadcbc365f28e5ec3e80037ebbb8ae7a79e5162
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b9f6e9c9b3afb9e407f22d5cec7429e03bf196478bd513f74200da3c2449143c17997f49cf38e9bf32234ae75063cd4086c95ee828735b0108f5299132cdabe
|
7
|
+
data.tar.gz: f2af751a0a0c1abc468ad7d675d9d4960c856f4278e87a86e4d19fd96a824a49f6976fd3e2879586d0f42b1fbcd47dabb22008d0d6a912f6e83b116cab33c1f9
|
data/.travis.yml
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
language: ruby
|
2
2
|
|
3
3
|
rvm:
|
4
|
-
- 2.0
|
5
4
|
- 2.1
|
6
5
|
- 2.2.5
|
7
|
-
- 2.3.
|
6
|
+
- 2.3.3
|
7
|
+
- 2.4.0
|
8
8
|
- ruby-head
|
9
|
-
- rbx
|
10
9
|
|
11
10
|
gemfile:
|
12
11
|
- Gemfile
|
@@ -23,8 +22,5 @@ sudo: false
|
|
23
22
|
|
24
23
|
matrix:
|
25
24
|
allow_failures:
|
25
|
+
- rvm: 2.4.0
|
26
26
|
- rvm: ruby-head
|
27
|
-
- rvm: rbx
|
28
|
-
exclude:
|
29
|
-
- rvm: 2.0
|
30
|
-
gemfile: Gemfile
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
## ChangeLog
|
2
2
|
|
3
|
+
### Release 0.3.4 - 2017/01/03
|
4
|
+
|
5
|
+
- Output plugin
|
6
|
+
- Rescue 50x errors
|
7
|
+
- Input plugin
|
8
|
+
- Guard emit to be called with multi-threading
|
9
|
+
- Rescue 50x errors
|
10
|
+
- Enabled to select whether to raise an exception if message processing failed
|
11
|
+
|
3
12
|
### Release 0.3.3 - 2016/12/03
|
4
13
|
|
5
14
|
- Input plugin
|
data/README.md
CHANGED
@@ -7,10 +7,10 @@ This plugin is forked from https://github.com/mdoi/fluent-plugin-gcloud-pubsub
|
|
7
7
|
|
8
8
|
## Overview
|
9
9
|
|
10
|
-
[Cloud Pub/Sub](https://cloud.google.com/pubsub/) Input/Output(BufferedOutput) plugin for [Fluentd](http://www.fluentd.org/) with [
|
10
|
+
[Google Cloud Pub/Sub](https://cloud.google.com/pubsub/) Input/Output(BufferedOutput) plugin for [Fluentd](http://www.fluentd.org/) with [google-cloud](https://googlecloudplatform.github.io/google-cloud-ruby/) gem
|
11
11
|
|
12
|
-
-
|
13
|
-
-
|
12
|
+
- Publish messages to Google Cloud Pub/Sub
|
13
|
+
- Pull messages from Google Cloud Pub/Sub
|
14
14
|
|
15
15
|
## Preparation
|
16
16
|
|
@@ -96,6 +96,7 @@ Use `gcloud_pubsub` input plugin.
|
|
96
96
|
pull_interval 0.5
|
97
97
|
pull_threads 2
|
98
98
|
format json
|
99
|
+
parse_error_action exception
|
99
100
|
enable_rpc true
|
100
101
|
rpc_bind 0.0.0.0
|
101
102
|
rpc_port 24680
|
@@ -127,6 +128,10 @@ Use `gcloud_pubsub` input plugin.
|
|
127
128
|
- Set number of threads to pull messages.
|
128
129
|
- `format` (optional, default: `json`)
|
129
130
|
- Set input format. See format section in http://docs.fluentd.org/articles/in_tail
|
131
|
+
- `parse_error_action` (optional, default: `exception`)
|
132
|
+
- Set error type when parsing messages fails.
|
133
|
+
- `exception`: Raise exception. Messages are not acknowledged.
|
134
|
+
- `warning`: Only logging as warning.
|
130
135
|
- `enable_rpc` (optional, default: `false`)
|
131
136
|
- If `true` is specified, HTTP RPC to stop or start pulling message is enabled.
|
132
137
|
- `rpc_bind` (optional, default: `0.0.0.0`)
|
@@ -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.3.4
|
10
|
+
gem.version = "0.3.4"
|
11
11
|
gem.authors = ["Yoshihiro MIYAI"]
|
12
12
|
gem.email = "msparrow17@gmail.com"
|
13
13
|
gem.has_rdoc = false
|
@@ -21,7 +21,7 @@ module Fluent
|
|
21
21
|
batch.publish m
|
22
22
|
end
|
23
23
|
end
|
24
|
-
rescue Google::Cloud::UnavailableError, Google::Cloud::DeadlineExceededError => ex
|
24
|
+
rescue Google::Cloud::UnavailableError, Google::Cloud::DeadlineExceededError, Google::Cloud::InternalError => ex
|
25
25
|
raise RetryableError.new "Google api returns error:#{ex.class.to_s} message:#{ex.to_s}"
|
26
26
|
end
|
27
27
|
end
|
@@ -36,6 +36,8 @@ module Fluent
|
|
36
36
|
|
37
37
|
def pull(immediate, max)
|
38
38
|
@client.pull immediate: immediate, max: max
|
39
|
+
rescue Google::Cloud::UnavailableError, Google::Cloud::DeadlineExceededError, Google::Cloud::InternalError => ex
|
40
|
+
raise RetryableError.new "Google api returns error:#{ex.class.to_s} message:#{ex.to_s}"
|
39
41
|
end
|
40
42
|
|
41
43
|
def acknowledge(messages)
|
@@ -40,6 +40,8 @@ module Fluent
|
|
40
40
|
config_param :pull_threads, :integer, default: 1
|
41
41
|
desc 'Set input format.'
|
42
42
|
config_param :format, :string, default: 'json'
|
43
|
+
desc 'Set error type when parsing messages fails.'
|
44
|
+
config_param :parse_error_action, :enum, default: :exception, list: [:exception, :warning]
|
43
45
|
# for HTTP RPC
|
44
46
|
desc 'If `true` is specified, HTTP RPC to stop or start pulling message is enabled.'
|
45
47
|
config_param :enable_rpc, :bool, default: false
|
@@ -191,6 +193,8 @@ module Fluent
|
|
191
193
|
@subscriber.acknowledge messages
|
192
194
|
|
193
195
|
log.debug "#{messages.length} message(s) processed"
|
196
|
+
rescue Fluent::GcloudPubSub::RetryableError => ex
|
197
|
+
log.warn "Retryable error occurs. Fluentd will retry.", error_message: ex.to_s, error_class: ex.class.to_s
|
194
198
|
rescue => ex
|
195
199
|
log.error "unexpected error", error_message: ex.to_s, error_class: ex.class.to_s
|
196
200
|
log.error_backtrace ex.backtrace
|
@@ -204,7 +208,12 @@ module Fluent
|
|
204
208
|
if time && record
|
205
209
|
es.add(time, record)
|
206
210
|
else
|
207
|
-
|
211
|
+
case @parse_error_action
|
212
|
+
when :exception
|
213
|
+
raise FailedParseError.new "pattern not match: #{line.inspect}"
|
214
|
+
else
|
215
|
+
log.warn 'pattern not match', record: line.inspect
|
216
|
+
end
|
208
217
|
end
|
209
218
|
end
|
210
219
|
end
|
@@ -16,6 +16,17 @@ class GcloudPubSubInputTest < Test::Unit::TestCase
|
|
16
16
|
DEFAULT_HOST = '127.0.0.1'
|
17
17
|
DEFAULT_PORT = 24680
|
18
18
|
|
19
|
+
class DummyInvalidMsgData
|
20
|
+
def data
|
21
|
+
return 'foo:bar'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
class DummyInvalidMessage
|
25
|
+
def message
|
26
|
+
DummyInvalidMsgData.new
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
19
30
|
def create_driver(conf=CONFIG)
|
20
31
|
Fluent::Test::InputTestDriver.new(Fluent::GcloudPubSubInput).configure(conf)
|
21
32
|
end
|
@@ -143,18 +154,7 @@ class GcloudPubSubInputTest < Test::Unit::TestCase
|
|
143
154
|
end
|
144
155
|
end
|
145
156
|
|
146
|
-
test 'invalid messages' do
|
147
|
-
class DummyInvalidMsgData
|
148
|
-
def data
|
149
|
-
return 'foo:bar'
|
150
|
-
end
|
151
|
-
end
|
152
|
-
class DummyInvalidMessage
|
153
|
-
def message
|
154
|
-
DummyInvalidMsgData.new
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
157
|
+
test 'invalid messages with parse_error_action exception ' do
|
158
158
|
messages = Array.new(1, DummyInvalidMessage.new)
|
159
159
|
@subscriber.pull(immediate: true, max: 100).once { messages }
|
160
160
|
@subscriber.acknowledge.times(0)
|
@@ -166,6 +166,18 @@ class GcloudPubSubInputTest < Test::Unit::TestCase
|
|
166
166
|
assert_equal(true, d.emits.empty?)
|
167
167
|
end
|
168
168
|
|
169
|
+
test 'invalid messages with parse_error_action warning' do
|
170
|
+
messages = Array.new(1, DummyInvalidMessage.new)
|
171
|
+
@subscriber.pull(immediate: true, max: 100).once { messages }
|
172
|
+
@subscriber.acknowledge(messages).once
|
173
|
+
|
174
|
+
d = create_driver("#{CONFIG}\nparse_error_action warning")
|
175
|
+
d.run {
|
176
|
+
# d.run sleeps 0.5 sec
|
177
|
+
}
|
178
|
+
assert_equal(true, d.emits.empty?)
|
179
|
+
end
|
180
|
+
|
169
181
|
test 'retry if raised error' do
|
170
182
|
class UnknownError < StandardError
|
171
183
|
end
|
@@ -181,6 +193,19 @@ class GcloudPubSubInputTest < Test::Unit::TestCase
|
|
181
193
|
assert_equal(true, d.emits.empty?)
|
182
194
|
end
|
183
195
|
|
196
|
+
test 'retry if raised RetryableError' do
|
197
|
+
@subscriber.pull(immediate: true, max: 100).twice { raise Google::Cloud::UnavailableError.new('TEST') }
|
198
|
+
@subscriber.acknowledge.times(0)
|
199
|
+
|
200
|
+
d = create_driver(CONFIG + 'pull_interval 0.5')
|
201
|
+
d.run {
|
202
|
+
sleep 0.1 # + 0.5s
|
203
|
+
}
|
204
|
+
|
205
|
+
assert_equal(0.5, d.instance.pull_interval)
|
206
|
+
assert_equal(true, d.emits.empty?)
|
207
|
+
end
|
208
|
+
|
184
209
|
test 'stop by http rpc' do
|
185
210
|
messages = Array.new(1, DummyMessage.new)
|
186
211
|
@subscriber.pull(immediate: true, max: 100).once { messages }
|
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.3.4
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshihiro MIYAI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -136,12 +136,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
136
136
|
version: '0'
|
137
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
138
|
requirements:
|
139
|
-
- - "
|
139
|
+
- - ">="
|
140
140
|
- !ruby/object:Gem::Version
|
141
|
-
version:
|
141
|
+
version: '0'
|
142
142
|
requirements: []
|
143
143
|
rubyforge_project:
|
144
|
-
rubygems_version: 2.5.
|
144
|
+
rubygems_version: 2.5.2
|
145
145
|
signing_key:
|
146
146
|
specification_version: 4
|
147
147
|
summary: Google Cloud Pub/Sub input/output plugin for Fluentd event collector
|