fluent-plugin-gcloud-pubsub-custom 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bd7e53135bef7ce1f7ce3796659b6deb1ebaf6ff303755a84fdd886c4f46bf3
|
4
|
+
data.tar.gz: a04ddb36d5c0bceb7ac1fb8947b537ee0c38b9b26f6b5d5c53bb2ed034deb4e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0d6537d00021bb6d849ff7c9c9e8b4b233214826b098db649820a0a310d7d60170a8642db3b7b7acee2f83b70a392ad6a9ef8adbb47f22bc2d1be2022129d03
|
7
|
+
data.tar.gz: 2b742512024102940dd447f6450377684a1834c89582e38d6498957dc6219c5625afa49320f2c6c0139ff73bd7e98ad61085029b0c4794e3418c0324b0346bc0
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -61,6 +61,7 @@ Use `gcloud_pubsub` output plugin.
|
|
61
61
|
max_total_size 9800000
|
62
62
|
max_message_size 4000000
|
63
63
|
endpoint <Endpoint URL>
|
64
|
+
timeout 60
|
64
65
|
<buffer>
|
65
66
|
@type memory
|
66
67
|
flush_interval 1s
|
@@ -95,11 +96,15 @@ Use `gcloud_pubsub` output plugin.
|
|
95
96
|
- `max_message_size` (optional, default: `4000000` = `4MB`)
|
96
97
|
- Messages exceeding `max_message_size` are not published because Pub/Sub clients cannot receive it.
|
97
98
|
- `attribute_keys` (optional, default: `[]`)
|
98
|
-
- Publishing the set fields as attributes.
|
99
|
+
- Publishing the set fields as attributes generated from input message.
|
100
|
+
- `attribute_key_values` (optional, default: `{}`)
|
101
|
+
- Publishing the set fields as attributes generated from input params
|
99
102
|
- `endpoint`(optional)
|
100
103
|
- Set Pub/Sub service endpoint. For more information, see [Service Endpoints](https://cloud.google.com/pubsub/docs/reference/service_apis_overview#service_endpoints)
|
101
104
|
- `compression` (optional, default: `nil`)
|
102
105
|
- If set to `gzip`, messages will be compressed with gzip.
|
106
|
+
- `timeout` (optional)
|
107
|
+
- Set default timeout to use in publish requests.
|
103
108
|
|
104
109
|
### Pull messages
|
105
110
|
|
@@ -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.
|
10
|
+
gem.version = "1.6.0"
|
11
11
|
gem.authors = ["Yoshihiro MIYAI"]
|
12
12
|
gem.email = "msparrow17@gmail.com"
|
13
13
|
gem.files = `git ls-files`.split("\n")
|
@@ -24,8 +24,8 @@ module Fluent
|
|
24
24
|
end
|
25
25
|
|
26
26
|
class Publisher
|
27
|
-
def initialize(project, key, autocreate_topic, dest_project, endpoint)
|
28
|
-
@pubsub = Google::Cloud::Pubsub.new project_id: project, credentials: key, endpoint: endpoint
|
27
|
+
def initialize(project, key, autocreate_topic, dest_project, endpoint, timeout)
|
28
|
+
@pubsub = Google::Cloud::Pubsub.new project_id: project, credentials: key, endpoint: endpoint, timeout: timeout
|
29
29
|
@autocreate_topic = autocreate_topic
|
30
30
|
@dest_project = dest_project
|
31
31
|
@topics = {}
|
@@ -31,12 +31,16 @@ module Fluent::Plugin
|
|
31
31
|
config_param :max_total_size, :integer, :default => 9800000 # 9.8MB
|
32
32
|
desc 'Limit bytesize per message.'
|
33
33
|
config_param :max_message_size, :integer, :default => 4000000 # 4MB
|
34
|
-
desc 'Publishing the set field as an attribute'
|
34
|
+
desc 'Publishing the set field as an attribute created from input message'
|
35
35
|
config_param :attribute_keys, :array, :default => []
|
36
|
+
desc 'Publishing the set field as an attribute created from input config params'
|
37
|
+
config_param :attribute_key_values, :hash, :default => {}
|
36
38
|
desc 'Set service endpoint'
|
37
39
|
config_param :endpoint, :string, :default => nil
|
38
40
|
desc 'Compress messages'
|
39
41
|
config_param :compression, :string, :default => nil
|
42
|
+
desc 'Set default timeout to use in publish requests'
|
43
|
+
config_param :timeout, :integer, :default => nil
|
40
44
|
|
41
45
|
config_section :buffer do
|
42
46
|
config_set_default :@type, DEFAULT_BUFFER_TYPE
|
@@ -60,7 +64,7 @@ module Fluent::Plugin
|
|
60
64
|
|
61
65
|
def start
|
62
66
|
super
|
63
|
-
@publisher = Fluent::GcloudPubSub::Publisher.new @project, @key, @autocreate_topic, @dest_project, @endpoint
|
67
|
+
@publisher = Fluent::GcloudPubSub::Publisher.new @project, @key, @autocreate_topic, @dest_project, @endpoint, @timeout
|
64
68
|
end
|
65
69
|
|
66
70
|
def format(tag, time, record)
|
@@ -69,6 +73,7 @@ module Fluent::Plugin
|
|
69
73
|
@attribute_keys.each do |key|
|
70
74
|
attributes[key] = record.delete(key)
|
71
75
|
end
|
76
|
+
attributes.merge! @attribute_key_values
|
72
77
|
[@compress.call(@formatter.format(tag, time, record)), attributes].to_msgpack
|
73
78
|
end
|
74
79
|
|
@@ -3,6 +3,8 @@ require_relative "../helper"
|
|
3
3
|
require 'fluent/plugin/compressable'
|
4
4
|
require "fluent/test/driver/output"
|
5
5
|
require "fluent/test/helpers"
|
6
|
+
require 'json'
|
7
|
+
require 'msgpack'
|
6
8
|
|
7
9
|
class GcloudPubSubOutputTest < Test::Unit::TestCase
|
8
10
|
include Fluent::Test::Helpers
|
@@ -281,5 +283,66 @@ class GcloudPubSubOutputTest < Test::Unit::TestCase
|
|
281
283
|
|
282
284
|
assert_equal(test_msg, JSON.parse(decompress(MessagePack.unpack(d.formatted.first)[0])))
|
283
285
|
end
|
286
|
+
|
287
|
+
test 'with attribute_keys' do
|
288
|
+
d = create_driver(%[
|
289
|
+
project project-test
|
290
|
+
topic topic-test
|
291
|
+
key key-test
|
292
|
+
attribute_keys a,b
|
293
|
+
])
|
294
|
+
|
295
|
+
@publisher.publish.once
|
296
|
+
d.run(default_tag: "test") do
|
297
|
+
d.feed(@time, {"a" => "foo", "b" => "bar", "c" => "baz"})
|
298
|
+
end
|
299
|
+
|
300
|
+
formatted = MessagePack.unpack(d.formatted[0])
|
301
|
+
message = JSON.parse(formatted[0])
|
302
|
+
assert_equal(message, {"c" => "baz"})
|
303
|
+
attributes = formatted[1]
|
304
|
+
assert_equal(attributes, {"a" => "foo", "b" => "bar"})
|
305
|
+
end
|
306
|
+
|
307
|
+
test 'with attribute_key_values' do
|
308
|
+
d = create_driver(%[
|
309
|
+
project project-test
|
310
|
+
topic topic-test
|
311
|
+
key key-test
|
312
|
+
attribute_key_values {"key1": "value1", "key2": "value2"}
|
313
|
+
])
|
314
|
+
|
315
|
+
@publisher.publish.once
|
316
|
+
d.run(default_tag: "test") do
|
317
|
+
d.feed(@time, {"a" => "foo", "b" => "bar"})
|
318
|
+
end
|
319
|
+
|
320
|
+
formatted = MessagePack.unpack(d.formatted[0])
|
321
|
+
message = JSON.parse(formatted[0])
|
322
|
+
assert_equal(message, {"a" => "foo", "b" => "bar"})
|
323
|
+
attributes = formatted[1]
|
324
|
+
assert_equal(attributes, {"key1" => "value1", "key2" => "value2"})
|
325
|
+
end
|
326
|
+
|
327
|
+
test 'with attribute_keys and attribute_key_values' do
|
328
|
+
d = create_driver(%[
|
329
|
+
project project-test
|
330
|
+
topic topic-test
|
331
|
+
key key-test
|
332
|
+
attribute_keys a
|
333
|
+
attribute_key_values {"key": "value"}
|
334
|
+
])
|
335
|
+
|
336
|
+
@publisher.publish.once
|
337
|
+
d.run(default_tag: "test") do
|
338
|
+
d.feed(@time, {"a" => "foo", "b" => "bar"})
|
339
|
+
end
|
340
|
+
|
341
|
+
formatted = MessagePack.unpack(d.formatted[0])
|
342
|
+
message = JSON.parse(formatted[0])
|
343
|
+
assert_equal(message, {"b" => "bar"})
|
344
|
+
attributes = formatted[1]
|
345
|
+
assert_equal(attributes, {"a" => "foo", "key" => "value"})
|
346
|
+
end
|
284
347
|
end
|
285
348
|
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: 1.
|
4
|
+
version: 1.6.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: 2021-
|
11
|
+
date: 2021-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|