fluent-plugin-gcloud-pubsub-custom 1.3.2 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +4 -3
- data/CHANGELOG.md +7 -0
- data/README.md +2 -0
- data/fluent-plugin-gcloud-pubsub-custom.gemspec +2 -3
- data/lib/fluent/plugin/gcloud_pubsub/client.rb +9 -4
- data/lib/fluent/plugin/out_gcloud_pubsub.rb +3 -1
- data/test/plugin/test_out_gcloud_pubsub.rb +26 -0
- metadata +8 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 51c4af6bf7aee07e04161734152a796864a9a21924eab0e2434e45d177b4be0d
|
4
|
+
data.tar.gz: cd0bb6ec1e0b769b0e7792c5c8d5a797a5407ffca3dbe66f37bd1010959194ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f6f11c50da0f9396275e757a18cec552fdeeb8718e290a1388a2190bd26cb327704e6424848bf65a656e545f8cd6364ae571c285774cf82735a5512f0a57cd4
|
7
|
+
data.tar.gz: 62840bd5232d0f756c5ea09449f9821b2a55cee69d2fe0c048bfe764c4673fb389cde7b2b8c1b6d671a3f6def5d0d11587b080b15011fee1868079df7c35a4e8
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -81,6 +81,8 @@ Use `gcloud_pubsub` output plugin.
|
|
81
81
|
- `topic` (required)
|
82
82
|
- Set topic name to publish.
|
83
83
|
- You can use placeholder in this param. See: https://docs.fluentd.org/v1.0/articles/buffer-section
|
84
|
+
- `dest_project` (optional, default: `nil`)
|
85
|
+
- Set your destination GCP project if you publish messages cross project.
|
84
86
|
- `autocreate_topic` (optional, default: `false`)
|
85
87
|
- If set to `true`, specified topic will be created when it doesn't exist.
|
86
88
|
- `max_messages` (optional, default: `1000`)
|
@@ -7,17 +7,16 @@ 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.4.0"
|
11
11
|
gem.authors = ["Yoshihiro MIYAI"]
|
12
12
|
gem.email = "msparrow17@gmail.com"
|
13
|
-
gem.has_rdoc = false
|
14
13
|
gem.files = `git ls-files`.split("\n")
|
15
14
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
15
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
16
|
gem.require_paths = ['lib']
|
18
17
|
|
19
18
|
gem.add_runtime_dependency "fluentd", [">= 0.14.15", "< 2"]
|
20
|
-
gem.add_runtime_dependency "google-cloud-pubsub", "~> 0.
|
19
|
+
gem.add_runtime_dependency "google-cloud-pubsub", "~> 0.39.0"
|
21
20
|
|
22
21
|
gem.add_development_dependency "bundler"
|
23
22
|
gem.add_development_dependency "rake"
|
@@ -24,18 +24,23 @@ module Fluent
|
|
24
24
|
end
|
25
25
|
|
26
26
|
class Publisher
|
27
|
-
def initialize(project, key, autocreate_topic)
|
27
|
+
def initialize(project, key, autocreate_topic, dest_project)
|
28
28
|
@pubsub = Google::Cloud::Pubsub.new project_id: project, credentials: key
|
29
29
|
@autocreate_topic = autocreate_topic
|
30
|
+
@dest_project = dest_project
|
30
31
|
@topics = {}
|
31
32
|
end
|
32
33
|
|
33
34
|
def topic(topic_name)
|
34
35
|
return @topics[topic_name] if @topics.has_key? topic_name
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
client
|
37
|
+
if @dest_project.nil?
|
38
|
+
client = @pubsub.topic topic_name
|
39
|
+
if client.nil? && @autocreate_topic
|
40
|
+
client = @pubsub.create_topic topic_name
|
41
|
+
end
|
42
|
+
else
|
43
|
+
client = @pubsub.topic topic_name, project: @dest_project
|
39
44
|
end
|
40
45
|
if client.nil?
|
41
46
|
raise Error.new "topic:#{topic_name} does not exist."
|
@@ -19,6 +19,8 @@ module Fluent::Plugin
|
|
19
19
|
config_param :key, :string, :default => nil
|
20
20
|
desc 'Set topic name to publish.'
|
21
21
|
config_param :topic, :string
|
22
|
+
desc "Set your dest GCP project if publishing cross project"
|
23
|
+
config_param :dest_project, :string, :default => nil
|
22
24
|
desc "If set to `true`, specified topic will be created when it doesn't exist."
|
23
25
|
config_param :autocreate_topic, :bool, :default => false
|
24
26
|
desc 'Publishing messages count per request to Cloud Pub/Sub.'
|
@@ -47,7 +49,7 @@ module Fluent::Plugin
|
|
47
49
|
|
48
50
|
def start
|
49
51
|
super
|
50
|
-
@publisher = Fluent::GcloudPubSub::Publisher.new @project, @key, @autocreate_topic
|
52
|
+
@publisher = Fluent::GcloudPubSub::Publisher.new @project, @key, @autocreate_topic, @dest_project
|
51
53
|
end
|
52
54
|
|
53
55
|
def format(tag, time, record)
|
@@ -62,6 +62,17 @@ class GcloudPubSubOutputTest < Test::Unit::TestCase
|
|
62
62
|
|
63
63
|
assert_equal(true, d.instance.autocreate_topic)
|
64
64
|
end
|
65
|
+
|
66
|
+
test '"dest_project" can be specified' do
|
67
|
+
d = create_driver(%[
|
68
|
+
project project-test
|
69
|
+
topic topic-test
|
70
|
+
key key-test
|
71
|
+
dest_project dest-project-test
|
72
|
+
])
|
73
|
+
|
74
|
+
assert_equal("dest-project-test", d.instance.dest_project)
|
75
|
+
end
|
65
76
|
end
|
66
77
|
|
67
78
|
sub_test_case 'topic' do
|
@@ -87,6 +98,21 @@ class GcloudPubSubOutputTest < Test::Unit::TestCase
|
|
87
98
|
end
|
88
99
|
end
|
89
100
|
|
101
|
+
test '"dest_project" is set' do
|
102
|
+
d = create_driver(%[
|
103
|
+
project project-test
|
104
|
+
topic topic-test
|
105
|
+
key key-test
|
106
|
+
dest_project dest-project-test
|
107
|
+
])
|
108
|
+
|
109
|
+
@publisher.publish.once
|
110
|
+
@pubsub_mock.topic("topic-test", {:project=>"dest-project-test"}).once { @publisher }
|
111
|
+
d.run(default_tag: "test") do
|
112
|
+
d.feed(@time, {"a" => "b"})
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
90
116
|
test '40x error occurred on connecting to Pub/Sub' do
|
91
117
|
d = create_driver
|
92
118
|
|
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.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshihiro MIYAI
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -36,14 +36,14 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.
|
39
|
+
version: 0.39.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.
|
46
|
+
version: 0.39.0
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,7 +124,7 @@ homepage: https://github.com/mia-0032/fluent-plugin-gcloud-pubsub-custom
|
|
124
124
|
licenses:
|
125
125
|
- MIT
|
126
126
|
metadata: {}
|
127
|
-
post_install_message:
|
127
|
+
post_install_message:
|
128
128
|
rdoc_options: []
|
129
129
|
require_paths:
|
130
130
|
- lib
|
@@ -139,9 +139,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: '0'
|
141
141
|
requirements: []
|
142
|
-
|
143
|
-
|
144
|
-
signing_key:
|
142
|
+
rubygems_version: 3.1.2
|
143
|
+
signing_key:
|
145
144
|
specification_version: 4
|
146
145
|
summary: Google Cloud Pub/Sub input/output plugin for Fluentd event collector
|
147
146
|
test_files:
|