google-cloud-pubsub 0.33.2 → 0.34.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +4 -4
- data/CHANGELOG.md +45 -0
- data/EMULATOR.md +2 -2
- data/OVERVIEW.md +81 -43
- data/lib/google-cloud-pubsub.rb +10 -7
- data/lib/google/cloud/pubsub.rb +38 -21
- data/lib/google/cloud/pubsub/async_publisher.rb +8 -6
- data/lib/google/cloud/pubsub/batch_publisher.rb +7 -5
- data/lib/google/cloud/pubsub/convert.rb +5 -3
- data/lib/google/cloud/pubsub/credentials.rb +6 -4
- data/lib/google/cloud/pubsub/message.rb +9 -6
- data/lib/google/cloud/pubsub/policy.rb +12 -10
- data/lib/google/cloud/pubsub/project.rb +30 -28
- data/lib/google/cloud/pubsub/publish_result.rb +3 -1
- data/lib/google/cloud/pubsub/received_message.rb +11 -10
- data/lib/google/cloud/pubsub/service.rb +47 -37
- data/lib/google/cloud/pubsub/snapshot.rb +11 -9
- data/lib/google/cloud/pubsub/snapshot/list.rb +10 -8
- data/lib/google/cloud/pubsub/subscriber.rb +32 -6
- data/lib/google/cloud/pubsub/subscriber/enumerator_queue.rb +3 -1
- data/lib/google/cloud/pubsub/subscriber/inventory.rb +4 -2
- data/lib/google/cloud/pubsub/subscriber/stream.rb +23 -43
- data/lib/google/cloud/pubsub/subscriber/timed_unary_buffer.rb +221 -0
- data/lib/google/cloud/pubsub/subscription.rb +157 -80
- data/lib/google/cloud/pubsub/subscription/list.rb +12 -10
- data/lib/google/cloud/pubsub/topic.rb +79 -51
- data/lib/google/cloud/pubsub/topic/list.rb +10 -8
- data/lib/google/cloud/pubsub/v1/credentials.rb +4 -2
- data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/iam_policy.rb +1 -43
- data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/policy.rb +1 -108
- data/lib/google/cloud/pubsub/v1/doc/google/protobuf/duration.rb +1 -1
- data/lib/google/cloud/pubsub/v1/doc/google/protobuf/empty.rb +1 -1
- data/lib/google/cloud/pubsub/v1/doc/google/protobuf/field_mask.rb +1 -1
- data/lib/google/cloud/pubsub/v1/doc/google/protobuf/timestamp.rb +1 -1
- data/lib/google/cloud/pubsub/v1/doc/google/pubsub/v1/pubsub.rb +107 -61
- data/lib/google/cloud/pubsub/v1/publisher_client.rb +58 -55
- data/lib/google/cloud/pubsub/v1/publisher_client_config.json +0 -4
- data/lib/google/cloud/pubsub/v1/subscriber_client.rb +177 -128
- data/lib/google/cloud/pubsub/v1/subscriber_client_config.json +0 -4
- data/lib/google/cloud/pubsub/version.rb +4 -2
- data/lib/google/pubsub/v1/pubsub_pb.rb +48 -40
- data/lib/google/pubsub/v1/pubsub_services_pb.rb +201 -161
- metadata +6 -7
- data/lib/google/cloud/pubsub/subscriber/async_stream_pusher.rb +0 -223
- data/lib/google/cloud/pubsub/subscriber/async_unary_pusher.rb +0 -271
@@ -17,7 +17,7 @@ require "delegate"
|
|
17
17
|
|
18
18
|
module Google
|
19
19
|
module Cloud
|
20
|
-
module
|
20
|
+
module PubSub
|
21
21
|
class Subscription
|
22
22
|
##
|
23
23
|
# Subscription::List is a special case Array with additional values.
|
@@ -25,7 +25,7 @@ module Google
|
|
25
25
|
##
|
26
26
|
# If not empty, indicates that there are more subscriptions
|
27
27
|
# that match the request and this value should be passed to
|
28
|
-
# the next {Google::Cloud::
|
28
|
+
# the next {Google::Cloud::PubSub::Topic#subscriptions} to continue.
|
29
29
|
attr_accessor :token
|
30
30
|
|
31
31
|
##
|
@@ -46,7 +46,7 @@ module Google
|
|
46
46
|
# @example
|
47
47
|
# require "google/cloud/pubsub"
|
48
48
|
#
|
49
|
-
# pubsub = Google::Cloud::
|
49
|
+
# pubsub = Google::Cloud::PubSub.new
|
50
50
|
#
|
51
51
|
# subscriptions = pubsub.subscriptions
|
52
52
|
# if subscriptions.next?
|
@@ -65,7 +65,7 @@ module Google
|
|
65
65
|
# @example
|
66
66
|
# require "google/cloud/pubsub"
|
67
67
|
#
|
68
|
-
# pubsub = Google::Cloud::
|
68
|
+
# pubsub = Google::Cloud::PubSub.new
|
69
69
|
#
|
70
70
|
# subscriptions = pubsub.subscriptions
|
71
71
|
# if subscriptions.next?
|
@@ -103,7 +103,7 @@ module Google
|
|
103
103
|
# @example Iterating each subscription by passing a block:
|
104
104
|
# require "google/cloud/pubsub"
|
105
105
|
#
|
106
|
-
# pubsub = Google::Cloud::
|
106
|
+
# pubsub = Google::Cloud::PubSub.new
|
107
107
|
#
|
108
108
|
# subscriptions = pubsub.subscriptions
|
109
109
|
# subscriptions.all do |subscription|
|
@@ -113,7 +113,7 @@ module Google
|
|
113
113
|
# @example Using the enumerator by not passing a block:
|
114
114
|
# require "google/cloud/pubsub"
|
115
115
|
#
|
116
|
-
# pubsub = Google::Cloud::
|
116
|
+
# pubsub = Google::Cloud::PubSub.new
|
117
117
|
#
|
118
118
|
# subscriptions = pubsub.subscriptions
|
119
119
|
# all_names = subscriptions.all.map do |subscription|
|
@@ -123,7 +123,7 @@ module Google
|
|
123
123
|
# @example Limit the number of API calls made:
|
124
124
|
# require "google/cloud/pubsub"
|
125
125
|
#
|
126
|
-
# pubsub = Google::Cloud::
|
126
|
+
# pubsub = Google::Cloud::PubSub.new
|
127
127
|
#
|
128
128
|
# subscriptions = pubsub.subscriptions
|
129
129
|
# subscriptions.all(request_limit: 10) do |subscription|
|
@@ -149,7 +149,7 @@ module Google
|
|
149
149
|
|
150
150
|
##
|
151
151
|
# @private New Subscriptions::List from a
|
152
|
-
# Google::
|
152
|
+
# Google::Cloud::PubSub::V1::ListSubscriptionsRequest object.
|
153
153
|
def self.from_grpc grpc_list, service, max = nil
|
154
154
|
subs = new(Array(grpc_list.subscriptions).map do |grpc|
|
155
155
|
Subscription.from_grpc grpc, service
|
@@ -164,10 +164,10 @@ module Google
|
|
164
164
|
|
165
165
|
##
|
166
166
|
# @private New Subscriptions::List from a
|
167
|
-
# Google::
|
167
|
+
# Google::Cloud::PubSub::V1::ListTopicSubscriptionsResponse object.
|
168
168
|
def self.from_topic_grpc grpc_list, service, topic, max = nil
|
169
169
|
subs = new(Array(grpc_list.subscriptions).map do |grpc|
|
170
|
-
Subscription.
|
170
|
+
Subscription.from_name grpc, service
|
171
171
|
end)
|
172
172
|
token = grpc_list.next_page_token
|
173
173
|
token = nil if token == "".freeze
|
@@ -201,5 +201,7 @@ module Google
|
|
201
201
|
end
|
202
202
|
end
|
203
203
|
end
|
204
|
+
|
205
|
+
Pubsub = PubSub unless const_defined? :Pubsub
|
204
206
|
end
|
205
207
|
end
|
@@ -22,7 +22,7 @@ require "google/cloud/pubsub/policy"
|
|
22
22
|
|
23
23
|
module Google
|
24
24
|
module Cloud
|
25
|
-
module
|
25
|
+
module PubSub
|
26
26
|
##
|
27
27
|
# # Topic
|
28
28
|
#
|
@@ -33,7 +33,7 @@ module Google
|
|
33
33
|
# @example
|
34
34
|
# require "google/cloud/pubsub"
|
35
35
|
#
|
36
|
-
# pubsub = Google::Cloud::
|
36
|
+
# pubsub = Google::Cloud::PubSub.new
|
37
37
|
#
|
38
38
|
# topic = pubsub.topic "my-topic"
|
39
39
|
# topic.publish "task completed"
|
@@ -44,7 +44,7 @@ module Google
|
|
44
44
|
attr_accessor :service
|
45
45
|
|
46
46
|
##
|
47
|
-
# @private The Google::
|
47
|
+
# @private The Google::Cloud::PubSub::V1::Topic object.
|
48
48
|
attr_accessor :grpc
|
49
49
|
|
50
50
|
##
|
@@ -52,7 +52,7 @@ module Google
|
|
52
52
|
def initialize
|
53
53
|
@service = nil
|
54
54
|
@grpc = nil
|
55
|
-
@
|
55
|
+
@resource_name = nil
|
56
56
|
@exists = nil
|
57
57
|
@async_opts = {}
|
58
58
|
end
|
@@ -66,7 +66,7 @@ module Google
|
|
66
66
|
# @example
|
67
67
|
# require "google/cloud/pubsub"
|
68
68
|
#
|
69
|
-
# pubsub = Google::Cloud::
|
69
|
+
# pubsub = Google::Cloud::PubSub.new
|
70
70
|
#
|
71
71
|
# topic = pubsub.topic "my-topic"
|
72
72
|
# topic.publish_async "task completed" do |result|
|
@@ -90,6 +90,7 @@ module Google
|
|
90
90
|
# @return [String]
|
91
91
|
#
|
92
92
|
def name
|
93
|
+
return @resource_name if reference?
|
93
94
|
@grpc.name
|
94
95
|
end
|
95
96
|
|
@@ -101,9 +102,13 @@ module Google
|
|
101
102
|
# The returned hash is frozen and changes are not allowed. Use
|
102
103
|
# {#labels=} to update the labels for this topic.
|
103
104
|
#
|
105
|
+
# Makes an API call to retrieve the labels values when called on a
|
106
|
+
# reference object. See {#reference?}.
|
107
|
+
#
|
104
108
|
# @return [Hash] The frozen labels hash.
|
105
109
|
#
|
106
110
|
def labels
|
111
|
+
ensure_grpc!
|
107
112
|
@grpc.labels.to_h.freeze
|
108
113
|
end
|
109
114
|
|
@@ -121,12 +126,10 @@ module Google
|
|
121
126
|
#
|
122
127
|
def labels= new_labels
|
123
128
|
raise ArgumentError, "Value must be a Hash" if new_labels.nil?
|
124
|
-
|
125
|
-
|
126
|
-
update_grpc = @grpc.dup
|
127
|
-
update_grpc.labels = labels_map
|
129
|
+
update_grpc = Google::Cloud::PubSub::V1::Topic.new \
|
130
|
+
name: name, labels: new_labels
|
128
131
|
@grpc = service.update_topic update_grpc, :labels
|
129
|
-
@
|
132
|
+
@resource_name = nil
|
130
133
|
end
|
131
134
|
|
132
135
|
##
|
@@ -137,7 +140,7 @@ module Google
|
|
137
140
|
# @example
|
138
141
|
# require "google/cloud/pubsub"
|
139
142
|
#
|
140
|
-
# pubsub = Google::Cloud::
|
143
|
+
# pubsub = Google::Cloud::PubSub.new
|
141
144
|
#
|
142
145
|
# topic = pubsub.topic "my-topic"
|
143
146
|
# topic.delete
|
@@ -181,12 +184,12 @@ module Google
|
|
181
184
|
# label in the list must have a different key. See [Creating and
|
182
185
|
# Managing Labels](https://cloud.google.com/pubsub/docs/labels).
|
183
186
|
#
|
184
|
-
# @return [Google::Cloud::
|
187
|
+
# @return [Google::Cloud::PubSub::Subscription]
|
185
188
|
#
|
186
189
|
# @example
|
187
190
|
# require "google/cloud/pubsub"
|
188
191
|
#
|
189
|
-
# pubsub = Google::Cloud::
|
192
|
+
# pubsub = Google::Cloud::PubSub.new
|
190
193
|
#
|
191
194
|
# topic = pubsub.topic "my-topic"
|
192
195
|
# sub = topic.subscribe "my-topic-sub"
|
@@ -195,7 +198,7 @@ module Google
|
|
195
198
|
# @example Wait 2 minutes for acknowledgement and push all to endpoint:
|
196
199
|
# require "google/cloud/pubsub"
|
197
200
|
#
|
198
|
-
# pubsub = Google::Cloud::
|
201
|
+
# pubsub = Google::Cloud::PubSub.new
|
199
202
|
#
|
200
203
|
# topic = pubsub.topic "my-topic"
|
201
204
|
# sub = topic.subscribe "my-topic-sub",
|
@@ -222,13 +225,13 @@ module Google
|
|
222
225
|
# service. Calls made on this object will raise errors if the service
|
223
226
|
# resource does not exist. Default is `false`.
|
224
227
|
#
|
225
|
-
# @return [Google::Cloud::
|
228
|
+
# @return [Google::Cloud::PubSub::Subscription, nil] Returns `nil` if
|
226
229
|
# the subscription does not exist.
|
227
230
|
#
|
228
231
|
# @example
|
229
232
|
# require "google/cloud/pubsub"
|
230
233
|
#
|
231
|
-
# pubsub = Google::Cloud::
|
234
|
+
# pubsub = Google::Cloud::PubSub.new
|
232
235
|
#
|
233
236
|
# topic = pubsub.topic "my-topic"
|
234
237
|
#
|
@@ -238,7 +241,7 @@ module Google
|
|
238
241
|
# @example Skip the lookup against the service with `skip_lookup`:
|
239
242
|
# require "google/cloud/pubsub"
|
240
243
|
#
|
241
|
-
# pubsub = Google::Cloud::
|
244
|
+
# pubsub = Google::Cloud::PubSub.new
|
242
245
|
#
|
243
246
|
# topic = pubsub.topic "my-topic"
|
244
247
|
#
|
@@ -248,7 +251,9 @@ module Google
|
|
248
251
|
#
|
249
252
|
def subscription subscription_name, skip_lookup: nil
|
250
253
|
ensure_service!
|
251
|
-
|
254
|
+
if skip_lookup
|
255
|
+
return Subscription.from_name subscription_name, service
|
256
|
+
end
|
252
257
|
grpc = service.get_subscription subscription_name
|
253
258
|
Subscription.from_grpc grpc, service
|
254
259
|
rescue Google::Cloud::NotFoundError
|
@@ -270,7 +275,7 @@ module Google
|
|
270
275
|
# @example
|
271
276
|
# require "google/cloud/pubsub"
|
272
277
|
#
|
273
|
-
# pubsub = Google::Cloud::
|
278
|
+
# pubsub = Google::Cloud::PubSub.new
|
274
279
|
#
|
275
280
|
# topic = pubsub.topic "my-topic"
|
276
281
|
# subscriptions = topic.subscriptions
|
@@ -281,7 +286,7 @@ module Google
|
|
281
286
|
# @example Retrieve all subscriptions: (See {Subscription::List#all})
|
282
287
|
# require "google/cloud/pubsub"
|
283
288
|
#
|
284
|
-
# pubsub = Google::Cloud::
|
289
|
+
# pubsub = Google::Cloud::PubSub.new
|
285
290
|
#
|
286
291
|
# topic = pubsub.topic "my-topic"
|
287
292
|
# subscriptions = topic.subscriptions
|
@@ -319,7 +324,7 @@ module Google
|
|
319
324
|
# @example
|
320
325
|
# require "google/cloud/pubsub"
|
321
326
|
#
|
322
|
-
# pubsub = Google::Cloud::
|
327
|
+
# pubsub = Google::Cloud::PubSub.new
|
323
328
|
#
|
324
329
|
# topic = pubsub.topic "my-topic"
|
325
330
|
# msg = topic.publish "task completed"
|
@@ -327,7 +332,7 @@ module Google
|
|
327
332
|
# @example A message can be published using a File object:
|
328
333
|
# require "google/cloud/pubsub"
|
329
334
|
#
|
330
|
-
# pubsub = Google::Cloud::
|
335
|
+
# pubsub = Google::Cloud::PubSub.new
|
331
336
|
#
|
332
337
|
# topic = pubsub.topic "my-topic"
|
333
338
|
# file = File.open "message.txt", mode: "rb"
|
@@ -336,7 +341,7 @@ module Google
|
|
336
341
|
# @example Additionally, a message can be published with attributes:
|
337
342
|
# require "google/cloud/pubsub"
|
338
343
|
#
|
339
|
-
# pubsub = Google::Cloud::
|
344
|
+
# pubsub = Google::Cloud::PubSub.new
|
340
345
|
#
|
341
346
|
# topic = pubsub.topic "my-topic"
|
342
347
|
# msg = topic.publish "task completed",
|
@@ -346,7 +351,7 @@ module Google
|
|
346
351
|
# @example Multiple messages can be sent at the same time using a block:
|
347
352
|
# require "google/cloud/pubsub"
|
348
353
|
#
|
349
|
-
# pubsub = Google::Cloud::
|
354
|
+
# pubsub = Google::Cloud::PubSub.new
|
350
355
|
#
|
351
356
|
# topic = pubsub.topic "my-topic"
|
352
357
|
# msgs = topic.publish do |t|
|
@@ -379,7 +384,7 @@ module Google
|
|
379
384
|
# @example
|
380
385
|
# require "google/cloud/pubsub"
|
381
386
|
#
|
382
|
-
# pubsub = Google::Cloud::
|
387
|
+
# pubsub = Google::Cloud::PubSub.new
|
383
388
|
#
|
384
389
|
# topic = pubsub.topic "my-topic"
|
385
390
|
# topic.publish_async "task completed" do |result|
|
@@ -395,7 +400,7 @@ module Google
|
|
395
400
|
# @example A message can be published using a File object:
|
396
401
|
# require "google/cloud/pubsub"
|
397
402
|
#
|
398
|
-
# pubsub = Google::Cloud::
|
403
|
+
# pubsub = Google::Cloud::PubSub.new
|
399
404
|
#
|
400
405
|
# topic = pubsub.topic "my-topic"
|
401
406
|
# file = File.open "message.txt", mode: "rb"
|
@@ -406,7 +411,7 @@ module Google
|
|
406
411
|
# @example Additionally, a message can be published with attributes:
|
407
412
|
# require "google/cloud/pubsub"
|
408
413
|
#
|
409
|
-
# pubsub = Google::Cloud::
|
414
|
+
# pubsub = Google::Cloud::PubSub.new
|
410
415
|
#
|
411
416
|
# topic = pubsub.topic "my-topic"
|
412
417
|
# topic.publish_async "task completed",
|
@@ -440,7 +445,7 @@ module Google
|
|
440
445
|
# @example
|
441
446
|
# require "google/cloud/pubsub"
|
442
447
|
#
|
443
|
-
# pubsub = Google::Cloud::
|
448
|
+
# pubsub = Google::Cloud::PubSub.new
|
444
449
|
# topic = pubsub.topic "my-topic"
|
445
450
|
#
|
446
451
|
# policy = topic.policy
|
@@ -448,7 +453,7 @@ module Google
|
|
448
453
|
# @example Update the policy by passing a block:
|
449
454
|
# require "google/cloud/pubsub"
|
450
455
|
#
|
451
|
-
# pubsub = Google::Cloud::
|
456
|
+
# pubsub = Google::Cloud::PubSub.new
|
452
457
|
# topic = pubsub.topic "my-topic"
|
453
458
|
#
|
454
459
|
# topic.policy do |p|
|
@@ -467,7 +472,7 @@ module Google
|
|
467
472
|
##
|
468
473
|
# Updates the [Cloud IAM](https://cloud.google.com/iam/) access control
|
469
474
|
# policy for this topic. The policy should be read from {#policy}. See
|
470
|
-
# {Google::Cloud::
|
475
|
+
# {Google::Cloud::PubSub::Policy} for an explanation of the policy
|
471
476
|
# `etag` property and how to modify policies.
|
472
477
|
#
|
473
478
|
# You can also update the policy by passing a block to {#policy}, which
|
@@ -484,7 +489,7 @@ module Google
|
|
484
489
|
# @example
|
485
490
|
# require "google/cloud/pubsub"
|
486
491
|
#
|
487
|
-
# pubsub = Google::Cloud::
|
492
|
+
# pubsub = Google::Cloud::PubSub.new
|
488
493
|
# topic = pubsub.topic "my-topic"
|
489
494
|
#
|
490
495
|
# policy = topic.policy # API call
|
@@ -526,7 +531,7 @@ module Google
|
|
526
531
|
# @example
|
527
532
|
# require "google/cloud/pubsub"
|
528
533
|
#
|
529
|
-
# pubsub = Google::Cloud::
|
534
|
+
# pubsub = Google::Cloud::PubSub.new
|
530
535
|
# topic = pubsub.topic "my-topic"
|
531
536
|
# perms = topic.test_permissions "pubsub.topics.get",
|
532
537
|
# "pubsub.topics.publish"
|
@@ -547,14 +552,14 @@ module Google
|
|
547
552
|
# @example
|
548
553
|
# require "google/cloud/pubsub"
|
549
554
|
#
|
550
|
-
# pubsub = Google::Cloud::
|
555
|
+
# pubsub = Google::Cloud::PubSub.new
|
551
556
|
#
|
552
557
|
# topic = pubsub.topic "my-topic"
|
553
558
|
# topic.exists? #=> true
|
554
559
|
#
|
555
560
|
def exists?
|
556
|
-
# Always true if the object is not set as
|
557
|
-
return true unless
|
561
|
+
# Always true if the object is not set as reference
|
562
|
+
return true unless reference?
|
558
563
|
# If we have a value, return it
|
559
564
|
return @exists unless @exists.nil?
|
560
565
|
ensure_grpc!
|
@@ -564,23 +569,45 @@ module Google
|
|
564
569
|
end
|
565
570
|
|
566
571
|
##
|
567
|
-
#
|
568
|
-
#
|
572
|
+
# Determines whether the topic object was created without retrieving the
|
573
|
+
# resource representation from the Pub/Sub service.
|
574
|
+
#
|
575
|
+
# @return [Boolean] `true` when the topic was created without a resource
|
576
|
+
# representation, `false` otherwise.
|
569
577
|
#
|
570
578
|
# @example
|
571
579
|
# require "google/cloud/pubsub"
|
572
580
|
#
|
573
|
-
# pubsub = Google::Cloud::
|
581
|
+
# pubsub = Google::Cloud::PubSub.new
|
582
|
+
#
|
583
|
+
# topic = pubsub.topic "my-topic", skip_lookup: true
|
584
|
+
# topic.reference? #=> true
|
585
|
+
#
|
586
|
+
def reference?
|
587
|
+
@grpc.nil?
|
588
|
+
end
|
589
|
+
|
590
|
+
##
|
591
|
+
# Determines whether the topic object was created with a resource
|
592
|
+
# representation from the Pub/Sub service.
|
593
|
+
#
|
594
|
+
# @return [Boolean] `true` when the topic was created with a resource
|
595
|
+
# representation, `false` otherwise.
|
596
|
+
#
|
597
|
+
# @example
|
598
|
+
# require "google/cloud/pubsub"
|
599
|
+
#
|
600
|
+
# pubsub = Google::Cloud::PubSub.new
|
574
601
|
#
|
575
602
|
# topic = pubsub.topic "my-topic"
|
576
|
-
# topic.
|
603
|
+
# topic.resource? #=> true
|
577
604
|
#
|
578
|
-
def
|
579
|
-
|
605
|
+
def resource?
|
606
|
+
!@grpc.nil?
|
580
607
|
end
|
581
608
|
|
582
609
|
##
|
583
|
-
# @private New Topic from a Google::
|
610
|
+
# @private New Topic from a Google::Cloud::PubSub::V1::Topic object.
|
584
611
|
def self.from_grpc grpc, service, async: nil
|
585
612
|
new.tap do |t|
|
586
613
|
t.grpc = grpc
|
@@ -590,12 +617,11 @@ module Google
|
|
590
617
|
end
|
591
618
|
|
592
619
|
##
|
593
|
-
# @private New
|
594
|
-
def self.
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
t.instance_variable_set :@lazy, true
|
620
|
+
# @private New reference {Topic} object without making an HTTP request.
|
621
|
+
def self.from_name name, service, options = {}
|
622
|
+
name = service.topic_path name, options
|
623
|
+
from_grpc(nil, service).tap do |t|
|
624
|
+
t.instance_variable_set :@resource_name, name
|
599
625
|
end
|
600
626
|
end
|
601
627
|
|
@@ -609,11 +635,11 @@ module Google
|
|
609
635
|
end
|
610
636
|
|
611
637
|
##
|
612
|
-
# Ensures a Google::
|
638
|
+
# Ensures a Google::Cloud::PubSub::V1::Topic object exists.
|
613
639
|
def ensure_grpc!
|
614
640
|
ensure_service!
|
615
|
-
@grpc = service.get_topic name if
|
616
|
-
@
|
641
|
+
@grpc = service.get_topic name if reference?
|
642
|
+
@resource_name = nil
|
617
643
|
end
|
618
644
|
|
619
645
|
##
|
@@ -624,5 +650,7 @@ module Google
|
|
624
650
|
end
|
625
651
|
end
|
626
652
|
end
|
653
|
+
|
654
|
+
Pubsub = PubSub unless const_defined? :Pubsub
|
627
655
|
end
|
628
656
|
end
|