google-cloud-pubsub 0.20.0 → 2.6.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 +5 -5
- data/.yardopts +18 -0
- data/AUTHENTICATION.md +178 -0
- data/CHANGELOG.md +659 -0
- data/CODE_OF_CONDUCT.md +40 -0
- data/CONTRIBUTING.md +187 -0
- data/EMULATOR.md +37 -0
- data/LICENSE +201 -0
- data/LOGGING.md +32 -0
- data/OVERVIEW.md +528 -0
- data/TROUBLESHOOTING.md +31 -0
- data/lib/google/cloud/pubsub/async_publisher/batch.rb +310 -0
- data/lib/google/cloud/pubsub/async_publisher.rb +402 -0
- data/lib/google/cloud/pubsub/batch_publisher.rb +100 -0
- data/lib/google/cloud/pubsub/convert.rb +91 -0
- data/lib/google/cloud/pubsub/credentials.rb +26 -10
- data/lib/google/cloud/pubsub/errors.rb +85 -0
- data/lib/google/cloud/pubsub/message.rb +82 -20
- data/lib/google/cloud/pubsub/policy.rb +40 -61
- data/lib/google/cloud/pubsub/project.rb +405 -265
- data/lib/google/cloud/pubsub/publish_result.rb +103 -0
- data/lib/google/cloud/pubsub/received_message.rb +165 -30
- data/lib/google/cloud/pubsub/retry_policy.rb +88 -0
- data/lib/google/cloud/pubsub/schema/list.rb +180 -0
- data/lib/google/cloud/pubsub/schema.rb +310 -0
- data/lib/google/cloud/pubsub/service.rb +304 -162
- data/lib/google/cloud/pubsub/snapshot/list.rb +178 -0
- data/lib/google/cloud/pubsub/snapshot.rb +205 -0
- data/lib/google/cloud/pubsub/subscriber/enumerator_queue.rb +54 -0
- data/lib/google/cloud/pubsub/subscriber/inventory.rb +173 -0
- data/lib/google/cloud/pubsub/subscriber/sequencer.rb +115 -0
- data/lib/google/cloud/pubsub/subscriber/stream.rb +400 -0
- data/lib/google/cloud/pubsub/subscriber/timed_unary_buffer.rb +230 -0
- data/lib/google/cloud/pubsub/subscriber.rb +417 -0
- data/lib/google/cloud/pubsub/subscription/list.rb +38 -43
- data/lib/google/cloud/pubsub/subscription/push_config.rb +268 -0
- data/lib/google/cloud/pubsub/subscription.rb +1040 -210
- data/lib/google/cloud/pubsub/topic/list.rb +32 -37
- data/lib/google/cloud/pubsub/topic.rb +726 -177
- data/lib/google/cloud/pubsub/version.rb +6 -4
- data/lib/google/cloud/pubsub.rb +138 -413
- data/lib/google-cloud-pubsub.rb +60 -42
- metadata +88 -39
- data/lib/google/cloud/pubsub/topic/publisher.rb +0 -87
- data/lib/google/iam/v1/iam_policy.rb +0 -33
- data/lib/google/iam/v1/iam_policy_services.rb +0 -30
- data/lib/google/iam/v1/policy.rb +0 -25
- data/lib/google/pubsub/v1/pubsub_pb.rb +0 -129
- data/lib/google/pubsub/v1/pubsub_services_pb.rb +0 -117
data/lib/google-cloud-pubsub.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
# Copyright 2016 Google
|
1
|
+
# Copyright 2016 Google LLC
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
5
5
|
# You may obtain a copy of the License at
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
8
|
#
|
9
9
|
# Unless required by applicable law or agreed to in writing, software
|
10
10
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
@@ -12,14 +12,17 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
+
|
15
16
|
##
|
16
|
-
# This file is here to be autorequired by bundler, so that the
|
17
|
-
# #
|
18
|
-
# be loaded until required and used.
|
17
|
+
# This file is here to be autorequired by bundler, so that the
|
18
|
+
# Google::Cloud.pubsub and Google::Cloud#pubsub methods can be available, but
|
19
|
+
# the library and all dependencies won't be loaded until required and used.
|
19
20
|
|
20
21
|
|
21
22
|
gem "google-cloud-core"
|
22
|
-
require "google/cloud"
|
23
|
+
require "google/cloud" unless defined? Google::Cloud.new
|
24
|
+
require "google/cloud/config"
|
25
|
+
require "googleauth"
|
23
26
|
|
24
27
|
module Google
|
25
28
|
module Cloud
|
@@ -27,8 +30,8 @@ module Google
|
|
27
30
|
# Creates a new object for connecting to the Pub/Sub service.
|
28
31
|
# Each call creates a new connection.
|
29
32
|
#
|
30
|
-
# For more information on connecting to Google Cloud see the
|
31
|
-
# Guide
|
33
|
+
# For more information on connecting to Google Cloud see the
|
34
|
+
# {file:AUTHENTICATION.md Authentication Guide}.
|
32
35
|
#
|
33
36
|
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
|
34
37
|
# set of resources and operations that the connection can access. See
|
@@ -38,11 +41,9 @@ module Google
|
|
38
41
|
# The default scope is:
|
39
42
|
#
|
40
43
|
# * `https://www.googleapis.com/auth/pubsub`
|
41
|
-
# @param [Integer] retries Number of times to retry requests on server
|
42
|
-
# error. The default value is `3`. Optional.
|
43
44
|
# @param [Integer] timeout Default timeout to use in requests. Optional.
|
44
45
|
#
|
45
|
-
# @return [Google::Cloud::
|
46
|
+
# @return [Google::Cloud::PubSub::Project]
|
46
47
|
#
|
47
48
|
# @example
|
48
49
|
# require "google/cloud"
|
@@ -59,23 +60,25 @@ module Google
|
|
59
60
|
# platform_scope = "https://www.googleapis.com/auth/cloud-platform"
|
60
61
|
# pubsub = gcloud.pubsub scope: platform_scope
|
61
62
|
#
|
62
|
-
def pubsub scope: nil,
|
63
|
-
|
64
|
-
|
65
|
-
timeout: (timeout || @timeout)
|
63
|
+
def pubsub scope: nil, timeout: nil
|
64
|
+
timeout ||= @timeout
|
65
|
+
Google::Cloud.pubsub @project, @keyfile, scope: scope, timeout: timeout
|
66
66
|
end
|
67
67
|
|
68
68
|
##
|
69
69
|
# Creates a new object for connecting to the Pub/Sub service.
|
70
70
|
# Each call creates a new connection.
|
71
71
|
#
|
72
|
-
# For more information on connecting to Google Cloud see the
|
73
|
-
# Guide
|
72
|
+
# For more information on connecting to Google Cloud see the
|
73
|
+
# {file:AUTHENTICATION.md Authentication Guide}.
|
74
74
|
#
|
75
|
-
# @param [String]
|
76
|
-
# connecting to.
|
77
|
-
#
|
78
|
-
#
|
75
|
+
# @param [String] project_id Project identifier for the Pub/Sub service you
|
76
|
+
# are connecting to. If not present, the default project for the
|
77
|
+
# credentials is used.
|
78
|
+
# @param [String, Hash, Google::Auth::Credentials] credentials The path to
|
79
|
+
# the keyfile as a String, the contents of the keyfile as a Hash, or a
|
80
|
+
# Google::Auth::Credentials object.
|
81
|
+
# (See {Google::Cloud::PubSub::Credentials})
|
79
82
|
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
|
80
83
|
# set of resources and operations that the connection can access. See
|
81
84
|
# [Using OAuth 2.0 to Access Google
|
@@ -84,39 +87,54 @@ module Google
|
|
84
87
|
# The default scope is:
|
85
88
|
#
|
86
89
|
# * `https://www.googleapis.com/auth/pubsub`
|
87
|
-
# @param [Integer] retries Number of times to retry requests on server
|
88
|
-
# error. The default value is `3`. Optional.
|
89
90
|
# @param [Integer] timeout Default timeout to use in requests. Optional.
|
90
91
|
#
|
91
|
-
# @return [Google::Cloud::
|
92
|
+
# @return [Google::Cloud::PubSub::Project]
|
92
93
|
#
|
93
94
|
# @example
|
94
|
-
# require "google/cloud
|
95
|
+
# require "google/cloud"
|
95
96
|
#
|
96
97
|
# pubsub = Google::Cloud.pubsub
|
97
98
|
#
|
98
99
|
# topic = pubsub.topic "my-topic"
|
99
100
|
# topic.publish "task completed"
|
100
101
|
#
|
101
|
-
def self.pubsub
|
102
|
+
def self.pubsub project_id = nil,
|
103
|
+
credentials = nil,
|
104
|
+
scope: nil,
|
102
105
|
timeout: nil
|
103
106
|
require "google/cloud/pubsub"
|
104
|
-
|
105
|
-
if ENV["PUBSUB_EMULATOR_HOST"]
|
106
|
-
ps = Google::Cloud::Pubsub::Project.new(
|
107
|
-
project, :this_channel_is_insecure)
|
108
|
-
ps.service.host = ENV["PUBSUB_EMULATOR_HOST"]
|
109
|
-
return ps
|
110
|
-
end
|
111
|
-
if keyfile.nil?
|
112
|
-
credentials = Google::Cloud::Pubsub::Credentials.default scope: scope
|
113
|
-
else
|
114
|
-
credentials = Google::Cloud::Pubsub::Credentials.new(
|
115
|
-
keyfile, scope: scope)
|
116
|
-
end
|
117
|
-
Google::Cloud::Pubsub::Project.new(
|
118
|
-
Google::Cloud::Pubsub::Service.new(
|
119
|
-
project, credentials, retries: retries, timeout: timeout))
|
107
|
+
Google::Cloud::PubSub.new project_id: project_id, credentials: credentials, scope: scope, timeout: timeout
|
120
108
|
end
|
121
109
|
end
|
122
110
|
end
|
111
|
+
|
112
|
+
# Set the default pubsub configuration
|
113
|
+
Google::Cloud.configure.add_config! :pubsub do |config|
|
114
|
+
default_project = Google::Cloud::Config.deferred do
|
115
|
+
ENV["PUBSUB_PROJECT"]
|
116
|
+
end
|
117
|
+
default_creds = Google::Cloud::Config.deferred do
|
118
|
+
Google::Cloud::Config.credentials_from_env(
|
119
|
+
"PUBSUB_CREDENTIALS", "PUBSUB_CREDENTIALS_JSON", "PUBSUB_KEYFILE", "PUBSUB_KEYFILE_JSON"
|
120
|
+
)
|
121
|
+
end
|
122
|
+
default_emulator = Google::Cloud::Config.deferred do
|
123
|
+
ENV["PUBSUB_EMULATOR_HOST"]
|
124
|
+
end
|
125
|
+
default_scopes = [
|
126
|
+
"https://www.googleapis.com/auth/cloud-platform",
|
127
|
+
"https://www.googleapis.com/auth/pubsub"
|
128
|
+
]
|
129
|
+
|
130
|
+
config.add_field! :project_id, default_project, match: String, allow_nil: true
|
131
|
+
config.add_alias! :project, :project_id
|
132
|
+
config.add_field! :credentials, default_creds, match: [String, Hash, Google::Auth::Credentials], allow_nil: true
|
133
|
+
config.add_alias! :keyfile, :credentials
|
134
|
+
config.add_field! :scope, default_scopes, match: [String, Array]
|
135
|
+
config.add_field! :quota_project, nil, match: String
|
136
|
+
config.add_field! :timeout, nil, match: Integer
|
137
|
+
config.add_field! :emulator_host, default_emulator, match: String, allow_nil: true
|
138
|
+
config.add_field! :on_error, nil, match: Proc
|
139
|
+
config.add_field! :endpoint, "pubsub.googleapis.com", match: String
|
140
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-pubsub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Moore
|
@@ -9,78 +9,106 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-04-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: concurrent-ruby
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: '1.1'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: '1.1'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: google-cloud-core
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '1.
|
34
|
+
version: '1.5'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '1.
|
41
|
+
version: '1.5'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name: google-
|
43
|
+
name: google-cloud-pubsub-v1
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '0.0'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
55
|
+
version: '0.0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: autotest-suffix
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '1.
|
63
|
-
type: :
|
62
|
+
version: '1.1'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.1'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: avro
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '1.10'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '1.10'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: google-style
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 1.25.1
|
91
|
+
type: :development
|
64
92
|
prerelease: false
|
65
93
|
version_requirements: !ruby/object:Gem::Requirement
|
66
94
|
requirements:
|
67
95
|
- - "~>"
|
68
96
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
97
|
+
version: 1.25.1
|
70
98
|
- !ruby/object:Gem::Dependency
|
71
99
|
name: minitest
|
72
100
|
requirement: !ruby/object:Gem::Requirement
|
73
101
|
requirements:
|
74
102
|
- - "~>"
|
75
103
|
- !ruby/object:Gem::Version
|
76
|
-
version: '5.
|
104
|
+
version: '5.14'
|
77
105
|
type: :development
|
78
106
|
prerelease: false
|
79
107
|
version_requirements: !ruby/object:Gem::Requirement
|
80
108
|
requirements:
|
81
109
|
- - "~>"
|
82
110
|
- !ruby/object:Gem::Version
|
83
|
-
version: '5.
|
111
|
+
version: '5.14'
|
84
112
|
- !ruby/object:Gem::Dependency
|
85
113
|
name: minitest-autotest
|
86
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,35 +152,35 @@ dependencies:
|
|
124
152
|
- !ruby/object:Gem::Version
|
125
153
|
version: '5.2'
|
126
154
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
155
|
+
name: redcarpet
|
128
156
|
requirement: !ruby/object:Gem::Requirement
|
129
157
|
requirements:
|
130
158
|
- - "~>"
|
131
159
|
- !ruby/object:Gem::Version
|
132
|
-
version: '
|
160
|
+
version: '3.0'
|
133
161
|
type: :development
|
134
162
|
prerelease: false
|
135
163
|
version_requirements: !ruby/object:Gem::Requirement
|
136
164
|
requirements:
|
137
165
|
- - "~>"
|
138
166
|
- !ruby/object:Gem::Version
|
139
|
-
version: '
|
167
|
+
version: '3.0'
|
140
168
|
- !ruby/object:Gem::Dependency
|
141
|
-
name:
|
169
|
+
name: simplecov
|
142
170
|
requirement: !ruby/object:Gem::Requirement
|
143
171
|
requirements:
|
144
|
-
- - "
|
172
|
+
- - "~>"
|
145
173
|
- !ruby/object:Gem::Version
|
146
|
-
version: 0.
|
174
|
+
version: '0.9'
|
147
175
|
type: :development
|
148
176
|
prerelease: false
|
149
177
|
version_requirements: !ruby/object:Gem::Requirement
|
150
178
|
requirements:
|
151
|
-
- - "
|
179
|
+
- - "~>"
|
152
180
|
- !ruby/object:Gem::Version
|
153
|
-
version: 0.
|
181
|
+
version: '0.9'
|
154
182
|
- !ruby/object:Gem::Dependency
|
155
|
-
name:
|
183
|
+
name: yard
|
156
184
|
requirement: !ruby/object:Gem::Requirement
|
157
185
|
requirements:
|
158
186
|
- - "~>"
|
@@ -166,19 +194,19 @@ dependencies:
|
|
166
194
|
- !ruby/object:Gem::Version
|
167
195
|
version: '0.9'
|
168
196
|
- !ruby/object:Gem::Dependency
|
169
|
-
name: yard
|
197
|
+
name: yard-doctest
|
170
198
|
requirement: !ruby/object:Gem::Requirement
|
171
199
|
requirements:
|
172
200
|
- - "~>"
|
173
201
|
- !ruby/object:Gem::Version
|
174
|
-
version:
|
202
|
+
version: 0.1.13
|
175
203
|
type: :development
|
176
204
|
prerelease: false
|
177
205
|
version_requirements: !ruby/object:Gem::Requirement
|
178
206
|
requirements:
|
179
207
|
- - "~>"
|
180
208
|
- !ruby/object:Gem::Version
|
181
|
-
version:
|
209
|
+
version: 0.1.13
|
182
210
|
description: google-cloud-pubsub is the official library for Google Cloud Pub/Sub.
|
183
211
|
email:
|
184
212
|
- mike@blowmage.com
|
@@ -187,26 +215,48 @@ executables: []
|
|
187
215
|
extensions: []
|
188
216
|
extra_rdoc_files: []
|
189
217
|
files:
|
218
|
+
- ".yardopts"
|
219
|
+
- AUTHENTICATION.md
|
220
|
+
- CHANGELOG.md
|
221
|
+
- CODE_OF_CONDUCT.md
|
222
|
+
- CONTRIBUTING.md
|
223
|
+
- EMULATOR.md
|
224
|
+
- LICENSE
|
225
|
+
- LOGGING.md
|
226
|
+
- OVERVIEW.md
|
227
|
+
- TROUBLESHOOTING.md
|
190
228
|
- lib/google-cloud-pubsub.rb
|
191
229
|
- lib/google/cloud/pubsub.rb
|
230
|
+
- lib/google/cloud/pubsub/async_publisher.rb
|
231
|
+
- lib/google/cloud/pubsub/async_publisher/batch.rb
|
232
|
+
- lib/google/cloud/pubsub/batch_publisher.rb
|
233
|
+
- lib/google/cloud/pubsub/convert.rb
|
192
234
|
- lib/google/cloud/pubsub/credentials.rb
|
235
|
+
- lib/google/cloud/pubsub/errors.rb
|
193
236
|
- lib/google/cloud/pubsub/message.rb
|
194
237
|
- lib/google/cloud/pubsub/policy.rb
|
195
238
|
- lib/google/cloud/pubsub/project.rb
|
239
|
+
- lib/google/cloud/pubsub/publish_result.rb
|
196
240
|
- lib/google/cloud/pubsub/received_message.rb
|
241
|
+
- lib/google/cloud/pubsub/retry_policy.rb
|
242
|
+
- lib/google/cloud/pubsub/schema.rb
|
243
|
+
- lib/google/cloud/pubsub/schema/list.rb
|
197
244
|
- lib/google/cloud/pubsub/service.rb
|
245
|
+
- lib/google/cloud/pubsub/snapshot.rb
|
246
|
+
- lib/google/cloud/pubsub/snapshot/list.rb
|
247
|
+
- lib/google/cloud/pubsub/subscriber.rb
|
248
|
+
- lib/google/cloud/pubsub/subscriber/enumerator_queue.rb
|
249
|
+
- lib/google/cloud/pubsub/subscriber/inventory.rb
|
250
|
+
- lib/google/cloud/pubsub/subscriber/sequencer.rb
|
251
|
+
- lib/google/cloud/pubsub/subscriber/stream.rb
|
252
|
+
- lib/google/cloud/pubsub/subscriber/timed_unary_buffer.rb
|
198
253
|
- lib/google/cloud/pubsub/subscription.rb
|
199
254
|
- lib/google/cloud/pubsub/subscription/list.rb
|
255
|
+
- lib/google/cloud/pubsub/subscription/push_config.rb
|
200
256
|
- lib/google/cloud/pubsub/topic.rb
|
201
257
|
- lib/google/cloud/pubsub/topic/list.rb
|
202
|
-
- lib/google/cloud/pubsub/topic/publisher.rb
|
203
258
|
- lib/google/cloud/pubsub/version.rb
|
204
|
-
|
205
|
-
- lib/google/iam/v1/iam_policy_services.rb
|
206
|
-
- lib/google/iam/v1/policy.rb
|
207
|
-
- lib/google/pubsub/v1/pubsub_pb.rb
|
208
|
-
- lib/google/pubsub/v1/pubsub_services_pb.rb
|
209
|
-
homepage: http://googlecloudplatform.github.io/google-cloud-ruby/
|
259
|
+
homepage: https://github.com/googleapis/google-cloud-ruby/tree/master/google-cloud-pubsub
|
210
260
|
licenses:
|
211
261
|
- Apache-2.0
|
212
262
|
metadata: {}
|
@@ -218,15 +268,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
218
268
|
requirements:
|
219
269
|
- - ">="
|
220
270
|
- !ruby/object:Gem::Version
|
221
|
-
version: 2.
|
271
|
+
version: '2.5'
|
222
272
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
223
273
|
requirements:
|
224
274
|
- - ">="
|
225
275
|
- !ruby/object:Gem::Version
|
226
276
|
version: '0'
|
227
277
|
requirements: []
|
228
|
-
|
229
|
-
rubygems_version: 2.6.4
|
278
|
+
rubygems_version: 3.2.16
|
230
279
|
signing_key:
|
231
280
|
specification_version: 4
|
232
281
|
summary: API Client library for Google Cloud Pub/Sub
|
@@ -1,87 +0,0 @@
|
|
1
|
-
# Copyright 2015 Google Inc. All rights reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
|
16
|
-
module Google
|
17
|
-
module Cloud
|
18
|
-
module Pubsub
|
19
|
-
class Topic
|
20
|
-
##
|
21
|
-
# Topic Publisher object used to publish multiple messages at once.
|
22
|
-
#
|
23
|
-
# @example
|
24
|
-
# require "google/cloud"
|
25
|
-
#
|
26
|
-
# gcloud = Google::Cloud.new
|
27
|
-
# pubsub = gcloud.pubsub
|
28
|
-
#
|
29
|
-
# topic = pubsub.topic "my-topic"
|
30
|
-
# msgs = topic.publish do |t|
|
31
|
-
# t.publish "new-message-1", foo: :bar
|
32
|
-
# t.publish "new-message-2", foo: :baz
|
33
|
-
# t.publish "new-message-3", foo: :bif
|
34
|
-
# end
|
35
|
-
class Publisher
|
36
|
-
##
|
37
|
-
# @private The messages to publish
|
38
|
-
attr_reader :messages
|
39
|
-
|
40
|
-
##
|
41
|
-
# @private Create a new instance of the object.
|
42
|
-
def initialize data = nil, attributes = {}
|
43
|
-
@messages = []
|
44
|
-
@mode = :batch
|
45
|
-
return if data.nil?
|
46
|
-
@mode = :single
|
47
|
-
publish data, attributes
|
48
|
-
end
|
49
|
-
|
50
|
-
##
|
51
|
-
# Add multiple messages to the topic.
|
52
|
-
# All messages added will be published at once.
|
53
|
-
# See {Google::Cloud::Pubsub::Topic#publish}
|
54
|
-
def publish data, attributes = {}
|
55
|
-
# Convert IO-ish objects to strings
|
56
|
-
if data.respond_to?(:read) && data.respond_to?(:rewind)
|
57
|
-
data.rewind
|
58
|
-
data = data.read
|
59
|
-
end
|
60
|
-
# Convert data to encoded byte array to match the protobuf defn
|
61
|
-
data = String(data).force_encoding("ASCII-8BIT")
|
62
|
-
# Convert attributes to strings to match the protobuf definition
|
63
|
-
attributes = Hash[attributes.map { |k, v| [String(k), String(v)] }]
|
64
|
-
@messages << [data, attributes]
|
65
|
-
end
|
66
|
-
|
67
|
-
##
|
68
|
-
# @private Create Message objects with message ids.
|
69
|
-
def to_gcloud_messages message_ids
|
70
|
-
msgs = @messages.zip(Array(message_ids)).map do |arr, id|
|
71
|
-
Message.from_grpc(
|
72
|
-
Google::Pubsub::V1::PubsubMessage.new(
|
73
|
-
data: arr[0], attributes: arr[1], message_id: id))
|
74
|
-
end
|
75
|
-
# Return just one Message if a single publish,
|
76
|
-
# otherwise return the array of Messages.
|
77
|
-
if @mode == :single && msgs.count <= 1
|
78
|
-
msgs.first
|
79
|
-
else
|
80
|
-
msgs
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|