fluent-plugin-gcloud-pubsub-custom 0.3.0 → 0.3.1

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: 6537f709d3f3e8849ae455fad4ee15a5f8b36d36
4
- data.tar.gz: 72ac72b492b01d4ac1301837f9faeaa185689f72
3
+ metadata.gz: fca9651c5d6e9f497579b5ee6ba6a42f2bb4e69a
4
+ data.tar.gz: d3a2a04f0e645a04a9828188715a4fab827cd4c6
5
5
  SHA512:
6
- metadata.gz: 21dfe776b5de4edfedc3cd71c47c050934db1b09ddb05f43a6d7c2fff0f7586e450bb669d7b5c9e5b7b5569dec176b6d1fed05f0aee12f3f01091c697f6cfe88
7
- data.tar.gz: 0c388a5d3eaf2edd941c81ba76676fc21ca9950b12c3fd6229f8e6981d6affc68ca33dc26d76a151fa4e7e752fbac33ff48cb0b3843b04542b2dd90605ac52d3
6
+ metadata.gz: 14806e97d5234bf531850e890b53066e65deb222e9eb602d509102f09496d38a8082568ae228a9ff74cfb544323327529422de22a39d1ac5c5977ea6208e27ea
7
+ data.tar.gz: e874e411b67cfaac3e0f13635661206fd50a812104d2ac0bb2cf68eb3d17f3c74d9b05797af1a4b14d9bd4f646602823631f96641640e61f6a2e1ce053a42698
data/CHANGELOG.md CHANGED
@@ -1,26 +1,44 @@
1
1
  ## ChangeLog
2
2
 
3
- - Release 0.3.0 - 2016/10/30
4
- - Bump up google-cloud-pubsub to v0.21
5
- - Input plugin
6
- - Add multithreaded pulling feature
7
- - Release 0.2.0 - 2016/10/15
8
- - Input plugin
9
- - Add HTTP RPC feature
10
- - Release 0.1.4 - 2016/09/19
11
- - Input plugin
12
- - `pull_interval` can be specified float value
13
- - `topic` must be specified
14
- - Release 0.1.3 - 2016/09/17
15
- - Input plugin
16
- - Fix error handling and add debug logging
17
- - Release 0.1.2 - 2016/09/11
18
- - Output plugin
19
- - Change default max message size and add debug message
20
- - Release 0.1.1 - 2016/08/27
21
- - Bump up google-cloud-pubsub (gcloud-ruby) to 0.20
22
- - Release 0.1.0 - 2016/08/22
23
- - Use formatter / parser plugin and add format configuration
24
- - Bump up gcloud-ruby to 0.12
25
- - Remove dependency on lightening buffer
26
- - Fix error caused by Pub/Sub quotas
3
+ ### Release 0.3.1 - 2016/11/03
4
+
5
+ - Output plugin
6
+ - Improve error handling
7
+
8
+ ### Release 0.3.0 - 2016/10/30
9
+
10
+ - Bump up google-cloud-pubsub to v0.21
11
+ - Input plugin
12
+ - Add multithreaded pulling feature
13
+
14
+ ### Release 0.2.0 - 2016/10/15
15
+
16
+ - Input plugin
17
+ - Add HTTP RPC feature
18
+
19
+ ### Release 0.1.4 - 2016/09/19
20
+
21
+ - Input plugin
22
+ - `pull_interval` can be specified float value
23
+ - `topic` must be specified
24
+
25
+ ### Release 0.1.3 - 2016/09/17
26
+
27
+ - Input plugin
28
+ - Fix error handling and add debug logging
29
+
30
+ ### Release 0.1.2 - 2016/09/11
31
+
32
+ - Output plugin
33
+ - Change default max message size and add debug message
34
+
35
+ ### Release 0.1.1 - 2016/08/27
36
+
37
+ - Bump up google-cloud-pubsub (gcloud-ruby) to 0.20
38
+
39
+ ### Release 0.1.0 - 2016/08/22
40
+
41
+ - Use formatter / parser plugin and add format configuration
42
+ - Bump up gcloud-ruby to 0.12
43
+ - Remove dependency on lightening buffer
44
+ - Fix error caused by Pub/Sub quotas
data/README.md CHANGED
@@ -88,6 +88,7 @@ Use `gcloud_pubsub` input plugin.
88
88
  max_messages 1000
89
89
  return_immediately true
90
90
  pull_interval 0.5
91
+ pull_threads 2
91
92
  format json
92
93
  enable_rpc true
93
94
  rpc_bind 0.0.0.0
@@ -116,6 +117,8 @@ Use `gcloud_pubsub` input plugin.
116
117
  - If `return_immediately` is `true` and pulling message is stopped by HTTP RPC, this plugin wait `pull_interval` each pull.
117
118
  - `pull_interval` (optional, default: `5.0`)
118
119
  - Pulling messages by intervals of specified seconds.
120
+ - `pull_threads` (optional, default: `1`)
121
+ - Set number of threads to pull messages.
119
122
  - `format` (optional, default: `json`)
120
123
  - Set input format. See format section in http://docs.fluentd.org/articles/in_tail
121
124
  - `enable_rpc` (optional, default: `false`)
@@ -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.0"
10
+ gem.version = "0.3.1"
11
11
  gem.authors = ["Yoshihiro MIYAI"]
12
12
  gem.email = "msparrow17@gmail.com"
13
13
  gem.has_rdoc = false
@@ -2,14 +2,17 @@ require 'google/cloud/pubsub'
2
2
 
3
3
  module Fluent
4
4
  module GcloudPubSub
5
- class Error < StandardError; end
5
+ class Error < StandardError
6
+ end
7
+ class RetryableError < Error
8
+ end
6
9
 
7
10
  class Publisher
8
11
  def initialize(project, key, topic, autocreate_topic)
9
12
  pubsub = Google::Cloud::Pubsub.new project: project, keyfile: key
10
13
 
11
14
  @client = pubsub.topic topic, autocreate: autocreate_topic
12
- raise Fluent::GcloudPubSub::Error.new "topic:#{topic} does not exist." if @client.nil?
15
+ raise Error.new "topic:#{topic} does not exist." if @client.nil?
13
16
  end
14
17
 
15
18
  def publish(messages)
@@ -18,6 +21,8 @@ module Fluent
18
21
  batch.publish m
19
22
  end
20
23
  end
24
+ rescue Google::Cloud::UnavailableError, Google::Cloud::DeadlineExceededError => ex
25
+ raise RetryableError.new "Google api returns error:#{ex.class.to_s} message:#{ex.to_s}"
21
26
  end
22
27
  end
23
28
 
@@ -26,7 +31,7 @@ module Fluent
26
31
  pubsub = Google::Cloud::Pubsub.new project: project, keyfile: key
27
32
  topic = pubsub.topic topic
28
33
  @client = topic.subscription subscription
29
- raise Fluent::GcloudPubSub::Error.new "subscription:#{subscription} does not exist." if @client.nil?
34
+ raise Error.new "subscription:#{subscription} does not exist." if @client.nil?
30
35
  end
31
36
 
32
37
  def pull(immediate, max)
@@ -35,15 +35,14 @@ module Fluent
35
35
  end
36
36
 
37
37
  def format(tag, time, record)
38
- [tag, time, record].to_msgpack
38
+ @formatter.format(tag, time, record).to_msgpack
39
39
  end
40
40
 
41
41
  def write(chunk)
42
42
  messages = []
43
43
  size = 0
44
44
 
45
- chunk.msgpack_each do |tag, time, record|
46
- msg = @formatter.format(tag, time, record)
45
+ chunk.msgpack_each do |msg|
47
46
  if messages.length + 1 > @max_messages || size + msg.bytesize > @max_total_size
48
47
  publish messages
49
48
  messages = []
@@ -56,10 +55,13 @@ module Fluent
56
55
  if messages.length > 0
57
56
  publish messages
58
57
  end
59
- rescue => e
60
- log.error "unexpected error", :error=>$!.to_s
58
+ rescue Fluent::GcloudPubSub::RetryableError => ex
59
+ log.warn "Retryable error occurs. Fluentd will retry.", error_message: ex.to_s, error_class: ex.class.to_s
60
+ raise ex
61
+ rescue => ex
62
+ log.error "unexpected error", error_message: ex.to_s, error_class: ex.class.to_s
61
63
  log.error_backtrace
62
- raise e
64
+ raise ex
63
65
  end
64
66
 
65
67
  private
@@ -120,7 +120,7 @@ class GcloudPubSubOutputTest < Test::Unit::TestCase
120
120
  d.run
121
121
  end
122
122
 
123
- test 'reraise errors' do
123
+ test 'reraise unexpected errors' do
124
124
  d = create_driver
125
125
  @publisher.publish.once { raise ReRaisedError }
126
126
  assert_raises ReRaisedError do
@@ -128,5 +128,14 @@ class GcloudPubSubOutputTest < Test::Unit::TestCase
128
128
  d.run
129
129
  end
130
130
  end
131
+
132
+ test 'reraise RetryableError' do
133
+ d = create_driver
134
+ @publisher.publish.once { raise Google::Cloud::UnavailableError.new('TEST') }
135
+ assert_raises Fluent::GcloudPubSub::RetryableError do
136
+ d.emit([{'a' => 1, 'b' => 2}])
137
+ d.run
138
+ end
139
+ end
131
140
  end
132
141
  end
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.0
4
+ version: 0.3.1
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-30 00:00:00.000000000 Z
11
+ date: 2016-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd