google-cloud-pubsub 0.20.1 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/google-cloud-pubsub.rb +13 -26
- data/lib/google/cloud/pubsub.rb +106 -86
- data/lib/google/cloud/pubsub/message.rb +2 -3
- data/lib/google/cloud/pubsub/policy.rb +13 -17
- data/lib/google/cloud/pubsub/project.rb +52 -73
- data/lib/google/cloud/pubsub/received_message.rb +6 -9
- data/lib/google/cloud/pubsub/service.rb +172 -152
- data/lib/google/cloud/pubsub/subscription.rb +41 -60
- data/lib/google/cloud/pubsub/subscription/list.rb +10 -15
- data/lib/google/cloud/pubsub/topic.rb +44 -64
- data/lib/google/cloud/pubsub/topic/list.rb +10 -15
- data/lib/google/cloud/pubsub/topic/publisher.rb +2 -3
- data/lib/google/cloud/pubsub/v1/publisher_api.rb +232 -11
- data/lib/google/cloud/pubsub/v1/publisher_client_config.json +15 -0
- data/lib/google/cloud/pubsub/v1/subscriber_api.rb +249 -17
- data/lib/google/cloud/pubsub/v1/subscriber_client_config.json +15 -0
- data/lib/google/cloud/pubsub/version.rb +1 -1
- data/lib/google/pubsub/v1/pubsub_services_pb.rb +6 -4
- metadata +36 -11
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fbe44f633b537eb6bc83e65289dd8245e2cf1f4
|
4
|
+
data.tar.gz: d3dde42ddf39bea98fdacda63376344b62abcd03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ed85872dd67b6a401a67ef656a056271ed0231500d7e589d3f3b9b8d3b381e5a74d612392639c95c7f3f1039b8226f410009a3dd5843ece2c9b5d02a7efe9b0
|
7
|
+
data.tar.gz: 673fb489421513dd5a9e63cef35c28536e1ba8fa0cf442c9c7b1d7db072bdee624c97cdb9d164a8fbe8b0ebaf484b0fcad58301163b9e0e5b1295efc38628e74
|
data/lib/google-cloud-pubsub.rb
CHANGED
@@ -38,9 +38,9 @@ module Google
|
|
38
38
|
# The default scope is:
|
39
39
|
#
|
40
40
|
# * `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
41
|
# @param [Integer] timeout Default timeout to use in requests. Optional.
|
42
|
+
# @param [Hash] client_config A hash of values to override the default
|
43
|
+
# behavior of the API client. Optional.
|
44
44
|
#
|
45
45
|
# @return [Google::Cloud::Pubsub::Project]
|
46
46
|
#
|
@@ -59,10 +59,10 @@ module Google
|
|
59
59
|
# platform_scope = "https://www.googleapis.com/auth/cloud-platform"
|
60
60
|
# pubsub = gcloud.pubsub scope: platform_scope
|
61
61
|
#
|
62
|
-
def pubsub scope: nil,
|
62
|
+
def pubsub scope: nil, timeout: nil, client_config: nil
|
63
63
|
Google::Cloud.pubsub @project, @keyfile, scope: scope,
|
64
|
-
|
65
|
-
|
64
|
+
timeout: (timeout || @timeout),
|
65
|
+
client_config: client_config
|
66
66
|
end
|
67
67
|
|
68
68
|
##
|
@@ -84,39 +84,26 @@ module Google
|
|
84
84
|
# The default scope is:
|
85
85
|
#
|
86
86
|
# * `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
87
|
# @param [Integer] timeout Default timeout to use in requests. Optional.
|
88
|
+
# @param [Hash] client_config A hash of values to override the default
|
89
|
+
# behavior of the API client. Optional.
|
90
90
|
#
|
91
91
|
# @return [Google::Cloud::Pubsub::Project]
|
92
92
|
#
|
93
93
|
# @example
|
94
|
-
# require "google/cloud
|
94
|
+
# require "google/cloud"
|
95
95
|
#
|
96
96
|
# pubsub = Google::Cloud.pubsub
|
97
97
|
#
|
98
98
|
# topic = pubsub.topic "my-topic"
|
99
99
|
# topic.publish "task completed"
|
100
100
|
#
|
101
|
-
def self.pubsub project = nil, keyfile = nil, scope: nil,
|
102
|
-
|
101
|
+
def self.pubsub project = nil, keyfile = nil, scope: nil, timeout: nil,
|
102
|
+
client_config: nil
|
103
103
|
require "google/cloud/pubsub"
|
104
|
-
|
105
|
-
|
106
|
-
|
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))
|
104
|
+
Google::Cloud::Pubsub.new project: project, keyfile: keyfile,
|
105
|
+
scope: scope, timeout: timeout,
|
106
|
+
client_config: client_config
|
120
107
|
end
|
121
108
|
end
|
122
109
|
end
|
data/lib/google/cloud/pubsub.rb
CHANGED
@@ -35,10 +35,9 @@ module Google
|
|
35
35
|
# is taken care of for you.
|
36
36
|
#
|
37
37
|
# ```ruby
|
38
|
-
# require "google/cloud"
|
38
|
+
# require "google/cloud/pubsub"
|
39
39
|
#
|
40
|
-
#
|
41
|
-
# pubsub = gcloud.pubsub
|
40
|
+
# pubsub = Google::Cloud::Pubsub.new
|
42
41
|
#
|
43
42
|
# topic = pubsub.topic "my-topic"
|
44
43
|
# topic.publish "task completed"
|
@@ -53,10 +52,9 @@ module Google
|
|
53
52
|
# A Topic is found by its name. (See {Google::Cloud::Pubsub::Project#topic})
|
54
53
|
#
|
55
54
|
# ```ruby
|
56
|
-
# require "google/cloud"
|
55
|
+
# require "google/cloud/pubsub"
|
57
56
|
#
|
58
|
-
#
|
59
|
-
# pubsub = gcloud.pubsub
|
57
|
+
# pubsub = Google::Cloud::Pubsub.new
|
60
58
|
# topic = pubsub.topic "my-topic"
|
61
59
|
# ```
|
62
60
|
#
|
@@ -66,10 +64,9 @@ module Google
|
|
66
64
|
# {Google::Cloud::Pubsub::Project#create_topic})
|
67
65
|
#
|
68
66
|
# ```ruby
|
69
|
-
# require "google/cloud"
|
67
|
+
# require "google/cloud/pubsub"
|
70
68
|
#
|
71
|
-
#
|
72
|
-
# pubsub = gcloud.pubsub
|
69
|
+
# pubsub = Google::Cloud::Pubsub.new
|
73
70
|
# topic = pubsub.create_topic "my-topic"
|
74
71
|
# ```
|
75
72
|
#
|
@@ -81,10 +78,9 @@ module Google
|
|
81
78
|
# {Google::Cloud::Pubsub::Topic#subscription})
|
82
79
|
#
|
83
80
|
# ```ruby
|
84
|
-
# require "google/cloud"
|
81
|
+
# require "google/cloud/pubsub"
|
85
82
|
#
|
86
|
-
#
|
87
|
-
# pubsub = gcloud.pubsub
|
83
|
+
# pubsub = Google::Cloud::Pubsub.new
|
88
84
|
#
|
89
85
|
# topic = pubsub.topic "my-topic"
|
90
86
|
# subscription = topic.subscription "my-topic-subscription"
|
@@ -98,10 +94,9 @@ module Google
|
|
98
94
|
# {Google::Cloud::Pubsub::Project#subscribe})
|
99
95
|
#
|
100
96
|
# ```ruby
|
101
|
-
# require "google/cloud"
|
97
|
+
# require "google/cloud/pubsub"
|
102
98
|
#
|
103
|
-
#
|
104
|
-
# pubsub = gcloud.pubsub
|
99
|
+
# pubsub = Google::Cloud::Pubsub.new
|
105
100
|
#
|
106
101
|
# topic = pubsub.topic "my-topic"
|
107
102
|
# sub = topic.subscribe "my-topic-sub"
|
@@ -113,10 +108,9 @@ module Google
|
|
113
108
|
# to:
|
114
109
|
#
|
115
110
|
# ```ruby
|
116
|
-
# require "google/cloud"
|
111
|
+
# require "google/cloud/pubsub"
|
117
112
|
#
|
118
|
-
#
|
119
|
-
# pubsub = gcloud.pubsub
|
113
|
+
# pubsub = Google::Cloud::Pubsub.new
|
120
114
|
#
|
121
115
|
# topic = pubsub.topic "my-topic"
|
122
116
|
# sub = topic.subscribe "my-topic-sub",
|
@@ -132,10 +126,9 @@ module Google
|
|
132
126
|
# {Google::Cloud::Pubsub::Project#publish})
|
133
127
|
#
|
134
128
|
# ```ruby
|
135
|
-
# require "google/cloud"
|
129
|
+
# require "google/cloud/pubsub"
|
136
130
|
#
|
137
|
-
#
|
138
|
-
# pubsub = gcloud.pubsub
|
131
|
+
# pubsub = Google::Cloud::Pubsub.new
|
139
132
|
#
|
140
133
|
# topic = pubsub.topic "my-topic"
|
141
134
|
# msg = topic.publish "new-message"
|
@@ -144,10 +137,9 @@ module Google
|
|
144
137
|
# Messages can also be published with attributes:
|
145
138
|
#
|
146
139
|
# ```ruby
|
147
|
-
# require "google/cloud"
|
140
|
+
# require "google/cloud/pubsub"
|
148
141
|
#
|
149
|
-
#
|
150
|
-
# pubsub = gcloud.pubsub
|
142
|
+
# pubsub = Google::Cloud::Pubsub.new
|
151
143
|
#
|
152
144
|
# topic = pubsub.topic "my-topic"
|
153
145
|
# msg = topic.publish "new-message",
|
@@ -158,10 +150,9 @@ module Google
|
|
158
150
|
# Multiple messages can be published at the same time by passing a block:
|
159
151
|
#
|
160
152
|
# ```ruby
|
161
|
-
# require "google/cloud"
|
153
|
+
# require "google/cloud/pubsub"
|
162
154
|
#
|
163
|
-
#
|
164
|
-
# pubsub = gcloud.pubsub
|
155
|
+
# pubsub = Google::Cloud::Pubsub.new
|
165
156
|
#
|
166
157
|
# topic = pubsub.topic "my-topic"
|
167
158
|
# msgs = topic.publish do |batch|
|
@@ -177,10 +168,9 @@ module Google
|
|
177
168
|
# {Google::Cloud::Pubsub::Subscription#pull})
|
178
169
|
#
|
179
170
|
# ```ruby
|
180
|
-
# require "google/cloud"
|
171
|
+
# require "google/cloud/pubsub"
|
181
172
|
#
|
182
|
-
#
|
183
|
-
# pubsub = gcloud.pubsub
|
173
|
+
# pubsub = Google::Cloud::Pubsub.new
|
184
174
|
#
|
185
175
|
# sub = pubsub.subscription "my-topic-sub"
|
186
176
|
# msgs = sub.pull
|
@@ -189,10 +179,9 @@ module Google
|
|
189
179
|
# A maximum number of messages returned can also be specified:
|
190
180
|
#
|
191
181
|
# ```ruby
|
192
|
-
# require "google/cloud"
|
182
|
+
# require "google/cloud/pubsub"
|
193
183
|
#
|
194
|
-
#
|
195
|
-
# pubsub = gcloud.pubsub
|
184
|
+
# pubsub = Google::Cloud::Pubsub.new
|
196
185
|
#
|
197
186
|
# sub = pubsub.subscription "my-topic-sub", max: 10
|
198
187
|
# msgs = sub.pull
|
@@ -202,10 +191,9 @@ module Google
|
|
202
191
|
# (See {Google::Cloud::Pubsub::Subscription#wait_for_messages})
|
203
192
|
#
|
204
193
|
# ```ruby
|
205
|
-
# require "google/cloud"
|
194
|
+
# require "google/cloud/pubsub"
|
206
195
|
#
|
207
|
-
#
|
208
|
-
# pubsub = gcloud.pubsub
|
196
|
+
# pubsub = Google::Cloud::Pubsub.new
|
209
197
|
#
|
210
198
|
# sub = pubsub.subscription "my-topic-sub"
|
211
199
|
# msgs = sub.wait_for_messages
|
@@ -221,10 +209,9 @@ module Google
|
|
221
209
|
# (See {Google::Cloud::Pubsub::ReceivedMessage#acknowledge!})
|
222
210
|
#
|
223
211
|
# ```ruby
|
224
|
-
# require "google/cloud"
|
212
|
+
# require "google/cloud/pubsub"
|
225
213
|
#
|
226
|
-
#
|
227
|
-
# pubsub = gcloud.pubsub
|
214
|
+
# pubsub = Google::Cloud::Pubsub.new
|
228
215
|
#
|
229
216
|
# sub = pubsub.subscription "my-topic-sub"
|
230
217
|
# sub.pull.each { |msg| msg.acknowledge! }
|
@@ -234,10 +221,9 @@ module Google
|
|
234
221
|
# (See {Google::Cloud::Pubsub::Subscription#acknowledge})
|
235
222
|
#
|
236
223
|
# ```ruby
|
237
|
-
# require "google/cloud"
|
224
|
+
# require "google/cloud/pubsub"
|
238
225
|
#
|
239
|
-
#
|
240
|
-
# pubsub = gcloud.pubsub
|
226
|
+
# pubsub = Google::Cloud::Pubsub.new
|
241
227
|
#
|
242
228
|
# sub = pubsub.subscription "my-topic-sub"
|
243
229
|
# received_messages = sub.pull
|
@@ -253,10 +239,9 @@ module Google
|
|
253
239
|
# {Google::Cloud::Pubsub::ReceivedMessage#delay!})
|
254
240
|
#
|
255
241
|
# ```ruby
|
256
|
-
# require "google/cloud"
|
242
|
+
# require "google/cloud/pubsub"
|
257
243
|
#
|
258
|
-
#
|
259
|
-
# pubsub = gcloud.pubsub
|
244
|
+
# pubsub = Google::Cloud::Pubsub.new
|
260
245
|
#
|
261
246
|
# sub = pubsub.subscription "my-topic-sub"
|
262
247
|
# received_message = sub.pull.first
|
@@ -270,10 +255,9 @@ module Google
|
|
270
255
|
# The message can also be made available for immediate redelivery:
|
271
256
|
#
|
272
257
|
# ```ruby
|
273
|
-
# require "google/cloud"
|
258
|
+
# require "google/cloud/pubsub"
|
274
259
|
#
|
275
|
-
#
|
276
|
-
# pubsub = gcloud.pubsub
|
260
|
+
# pubsub = Google::Cloud::Pubsub.new
|
277
261
|
#
|
278
262
|
# sub = pubsub.subscription "my-topic-sub"
|
279
263
|
# received_message = sub.pull.first
|
@@ -288,10 +272,9 @@ module Google
|
|
288
272
|
# redelivery: (See {Google::Cloud::Pubsub::Subscription#delay})
|
289
273
|
#
|
290
274
|
# ```ruby
|
291
|
-
# require "google/cloud"
|
275
|
+
# require "google/cloud/pubsub"
|
292
276
|
#
|
293
|
-
#
|
294
|
-
# pubsub = gcloud.pubsub
|
277
|
+
# pubsub = Google::Cloud::Pubsub.new
|
295
278
|
#
|
296
279
|
# sub = pubsub.subscription "my-topic-sub"
|
297
280
|
# received_messages = sub.pull
|
@@ -305,10 +288,9 @@ module Google
|
|
305
288
|
# {Google::Cloud::Pubsub::Subscription#listen})
|
306
289
|
#
|
307
290
|
# ```ruby
|
308
|
-
# require "google/cloud"
|
291
|
+
# require "google/cloud/pubsub"
|
309
292
|
#
|
310
|
-
#
|
311
|
-
# pubsub = gcloud.pubsub
|
293
|
+
# pubsub = Google::Cloud::Pubsub.new
|
312
294
|
#
|
313
295
|
# sub = pubsub.subscription "my-topic-sub"
|
314
296
|
# sub.listen do |msg|
|
@@ -320,10 +302,9 @@ module Google
|
|
320
302
|
# pulled per batch can be limited with the `max` option:
|
321
303
|
#
|
322
304
|
# ```ruby
|
323
|
-
# require "google/cloud"
|
305
|
+
# require "google/cloud/pubsub"
|
324
306
|
#
|
325
|
-
#
|
326
|
-
# pubsub = gcloud.pubsub
|
307
|
+
# pubsub = Google::Cloud::Pubsub.new
|
327
308
|
#
|
328
309
|
# sub = pubsub.subscription "my-topic-sub"
|
329
310
|
# sub.listen max: 20 do |msg|
|
@@ -336,10 +317,9 @@ module Google
|
|
336
317
|
# `autoack` option:
|
337
318
|
#
|
338
319
|
# ```ruby
|
339
|
-
# require "google/cloud"
|
320
|
+
# require "google/cloud/pubsub"
|
340
321
|
#
|
341
|
-
#
|
342
|
-
# pubsub = gcloud.pubsub
|
322
|
+
# pubsub = Google::Cloud::Pubsub.new
|
343
323
|
#
|
344
324
|
# sub = pubsub.subscription "my-topic-sub"
|
345
325
|
# sub.listen autoack: true do |msg|
|
@@ -347,29 +327,16 @@ module Google
|
|
347
327
|
# end
|
348
328
|
# ```
|
349
329
|
#
|
350
|
-
# ## Configuring
|
330
|
+
# ## Configuring timeout
|
351
331
|
#
|
352
|
-
# You can configure
|
353
|
-
# retried. When an API request fails, the response will be inspected to see
|
354
|
-
# if the request meets criteria indicating that it may succeed on retry,
|
355
|
-
# such as `500` and `503` status codes or a specific internal error code
|
356
|
-
# such as `rateLimitExceeded`. If it meets the criteria, the request will be
|
357
|
-
# retried after a delay. If another error occurs, the delay will be
|
358
|
-
# increased before a subsequent attempt, until the `retries` limit is
|
359
|
-
# reached.
|
360
|
-
#
|
361
|
-
# You can also set the request `timeout` value in seconds.
|
332
|
+
# You can configure the request `timeout` value in seconds.
|
362
333
|
#
|
363
334
|
# ```ruby
|
364
|
-
# require "google/cloud"
|
335
|
+
# require "google/cloud/pubsub"
|
365
336
|
#
|
366
|
-
#
|
367
|
-
# pubsub = gcloud.pubsub retries: 10, timeout: 120
|
337
|
+
# pubsub = Google::Cloud::Pubsub.new timeout: 120
|
368
338
|
# ```
|
369
339
|
#
|
370
|
-
# See the [Pub/Sub error codes](https://cloud.google.com/pubsub/error-codes)
|
371
|
-
# for a list of error conditions.
|
372
|
-
#
|
373
340
|
# ## Working Across Projects
|
374
341
|
#
|
375
342
|
# All calls to the Pub/Sub service use the same project and credentials
|
@@ -379,10 +346,9 @@ module Google
|
|
379
346
|
# to the topics and subscriptions in other projects.
|
380
347
|
#
|
381
348
|
# ```ruby
|
382
|
-
# require "google/cloud"
|
349
|
+
# require "google/cloud/pubsub"
|
383
350
|
#
|
384
|
-
#
|
385
|
-
# pubsub = gcloud.pubsub
|
351
|
+
# pubsub = Google::Cloud::Pubsub.new # my-project-id
|
386
352
|
#
|
387
353
|
# # Get a topic in the current project
|
388
354
|
# my_topic = pubsub.topic "my-topic"
|
@@ -396,10 +362,9 @@ module Google
|
|
396
362
|
# from a topic in another project:
|
397
363
|
#
|
398
364
|
# ```ruby
|
399
|
-
# require "google/cloud"
|
365
|
+
# require "google/cloud/pubsub"
|
400
366
|
#
|
401
|
-
#
|
402
|
-
# pubsub = gcloud.pubsub
|
367
|
+
# pubsub = Google::Cloud::Pubsub.new # my-project-id
|
403
368
|
#
|
404
369
|
# # Get a topic in another project
|
405
370
|
# topic = pubsub.topic "other-topic", project: "other-project-id"
|
@@ -426,13 +391,12 @@ module Google
|
|
426
391
|
# as shown below.
|
427
392
|
#
|
428
393
|
# ```ruby
|
429
|
-
# require "google/cloud"
|
394
|
+
# require "google/cloud/pubsub"
|
430
395
|
#
|
431
396
|
# # Make Pub/Sub use the emulator
|
432
397
|
# ENV["PUBSUB_EMULATOR_HOST"] = "localhost:8918"
|
433
398
|
#
|
434
|
-
#
|
435
|
-
# pubsub = gcloud.pubsub
|
399
|
+
# pubsub = Google::Cloud::Pubsub.new "emulator-project-id"
|
436
400
|
#
|
437
401
|
# # Get a topic in the current project
|
438
402
|
# my_topic = pubsub.new_topic "my-topic"
|
@@ -440,6 +404,62 @@ module Google
|
|
440
404
|
# ```
|
441
405
|
#
|
442
406
|
module Pubsub
|
407
|
+
##
|
408
|
+
# Creates a new object for connecting to the Pub/Sub service.
|
409
|
+
# Each call creates a new connection.
|
410
|
+
#
|
411
|
+
# For more information on connecting to Google Cloud see the
|
412
|
+
# [Authentication
|
413
|
+
# Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).
|
414
|
+
#
|
415
|
+
# @param [String] project Project identifier for the Pub/Sub service you
|
416
|
+
# are connecting to.
|
417
|
+
# @param [String, Hash] keyfile Keyfile downloaded from Google Cloud. If
|
418
|
+
# file path the file must be readable.
|
419
|
+
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling
|
420
|
+
# the set of resources and operations that the connection can access.
|
421
|
+
# See [Using OAuth 2.0 to Access Google
|
422
|
+
# APIs](https://developers.google.com/identity/protocols/OAuth2).
|
423
|
+
#
|
424
|
+
# The default scope is:
|
425
|
+
#
|
426
|
+
# * `https://www.googleapis.com/auth/pubsub`
|
427
|
+
# @param [Integer] timeout Default timeout to use in requests. Optional.
|
428
|
+
# @param [Hash] client_config A hash of values to override the default
|
429
|
+
# behavior of the API client. Optional.
|
430
|
+
#
|
431
|
+
# @return [Google::Cloud::Pubsub::Project]
|
432
|
+
#
|
433
|
+
# @example
|
434
|
+
# require "google/cloud/pubsub"
|
435
|
+
#
|
436
|
+
# pubsub = Google::Cloud.pubsub
|
437
|
+
#
|
438
|
+
# topic = pubsub.topic "my-topic"
|
439
|
+
# topic.publish "task completed"
|
440
|
+
#
|
441
|
+
def self.new project: nil, keyfile: nil, scope: nil, timeout: nil,
|
442
|
+
client_config: nil
|
443
|
+
project ||= Google::Cloud::Pubsub::Project.default_project
|
444
|
+
project = project.to_s # Always cast to a string
|
445
|
+
if ENV["PUBSUB_EMULATOR_HOST"]
|
446
|
+
ps = Google::Cloud::Pubsub::Project.new(
|
447
|
+
Google::Cloud::Pubsub::Service.new(
|
448
|
+
project, :this_channel_is_insecure))
|
449
|
+
ps.service.host = ENV["PUBSUB_EMULATOR_HOST"]
|
450
|
+
return ps
|
451
|
+
end
|
452
|
+
if keyfile.nil?
|
453
|
+
credentials = Google::Cloud::Pubsub::Credentials.default scope: scope
|
454
|
+
else
|
455
|
+
credentials = Google::Cloud::Pubsub::Credentials.new \
|
456
|
+
keyfile, scope: scope
|
457
|
+
end
|
458
|
+
Google::Cloud::Pubsub::Project.new(
|
459
|
+
Google::Cloud::Pubsub::Service.new(
|
460
|
+
project, credentials, timeout: timeout,
|
461
|
+
client_config: client_config))
|
462
|
+
end
|
443
463
|
end
|
444
464
|
end
|
445
465
|
end
|