google-cloud-pubsub 3.0.3 → 3.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7ddb29c5a0b1ae4716f853f703725e8d8fd0902a978b3ab0141a933b3b4664c
4
- data.tar.gz: 530004ebcdeac8a4be673a7a40ce7dae3e7771fb8102eb0878336046f7ca6063
3
+ metadata.gz: 0b807c188d7948862efc100d1d0c2bd06eb7495fe9031719e5c80f395093b491
4
+ data.tar.gz: 955a2d3cd3b3777a938a58e933c6aa8714a62ad21949daf8b7fd7efdfbd64091
5
5
  SHA512:
6
- metadata.gz: cd222027aab9e9b54f90bac0f1a6aa2269129da691bdea4f620c7133c15f003241a1f118ea8ae4fbb52f21fcbb1cbcfa0c2cabae1e26c330df61507a84316c14
7
- data.tar.gz: 2d386aea9fe41bb823653d594c6073342187c4fa9ba4651daaf30ea5c45050bdef08f84451c82efc5894ab2471b91db06f315de4276ebad6f1a23c942d965331
6
+ metadata.gz: 7f953960c1f7d30b5de38591d3f5c7c6ad27404ca99b93593ce8e41b772c3a5043731c861a9283bc7c15f1210ccb0aa3be8f50a94e46a73db5b835ab23402f59
7
+ data.tar.gz: 8e227ff927d181ef32dbcc85fe8dffcb9d66aa80fcc203d13fec166b83a05b92066c10423805269b40f7fd4a05530b1c30163560f4a955678fd704f00ea83f7f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Release History
2
2
 
3
+ ### 3.1.0 (2025-12-12)
4
+
5
+ #### Features
6
+
7
+ * Add skip_lookup to Project#publisher to enable lazy loading ([#32263](https://github.com/googleapis/google-cloud-ruby/issues/32263))
8
+ #### Documentation
9
+
10
+ * Fix overview documentation URL
11
+
3
12
  ### 3.0.3 (2025-11-04)
4
13
 
5
14
  #### Documentation
data/OVERVIEW.md CHANGED
@@ -36,7 +36,7 @@ into Admin Operations and Data Plane Operations.
36
36
  * **Data Plane Operations**: For the core functionality of publishing and receiving messages.
37
37
 
38
38
  To learn more about Pub/Sub, read the [Google Cloud Pub/Sub Overview
39
- ](https://cloud.google.com/pubsub/overview).
39
+ ](https://docs.cloud.google.com/pubsub/docs/overview).
40
40
 
41
41
  ## Admin Operations
42
42
 
@@ -133,12 +133,17 @@ module Google
133
133
  # @param [Hash] async A hash of values to configure the topic's
134
134
  # {AsyncPublisher} that is created when {Publisher#publish_async}
135
135
  # is called. Optional.
136
+ # @param [Boolean] skip_lookup Optionally create a {Publisher} object
137
+ # without verifying the topic resource exists on the Pub/Sub
138
+ # service. Calls made on this object will raise errors if the service
139
+ # resource does not exist. Default is `false`.
136
140
  #
137
141
  # @return [Google::Cloud::PubSub::Publisher]
138
142
  #
139
- def publisher topic_name, project: nil, async: nil
143
+ def publisher topic_name, project: nil, async: nil, skip_lookup: nil
140
144
  ensure_service!
141
145
  options = { project: project, async: async }
146
+ return Publisher.from_name topic_name, service, options if skip_lookup
142
147
  grpc = topic_admin.get_topic topic: service.topic_path(topic_name, options)
143
148
  Publisher.from_grpc grpc, service, async: async
144
149
  end
@@ -87,9 +87,56 @@ module Google
87
87
  # `projects/{project_id}/topics/{topic_id}`.
88
88
  #
89
89
  def name
90
+ return @resource_name if reference?
90
91
  @grpc.name
91
92
  end
92
93
 
94
+ ##
95
+ # Determines whether the publisher object was created with a resource
96
+ # representation from the Pub/Sub service.
97
+ #
98
+ # @return [Boolean] `true` when the publisher was created with a resource
99
+ # representation, `false` otherwise.
100
+ #
101
+ def reference?
102
+ @grpc.nil?
103
+ end
104
+
105
+ ##
106
+ # Determines whether the publisher object was created with a resource
107
+ # representation from the Pub/Sub service.
108
+ #
109
+ # @return [Boolean] `true` when the publisher was created with a resource
110
+ # representation, `false` otherwise.
111
+ #
112
+ def resource?
113
+ !@grpc.nil?
114
+ end
115
+
116
+
117
+ ##
118
+ # Reloads the publisher with current data from the Pub/Sub service.
119
+ #
120
+ # @return [Google::Cloud::PubSub::Publisher] Returns the reloaded
121
+ # publisher
122
+ #
123
+ # @example
124
+ # require "google/cloud/pubsub"
125
+ #
126
+ # pubsub = Google::Cloud::PubSub.new
127
+ #
128
+ # publisher = pubsub.publisher "my-topic", skip_lookup: true
129
+ #
130
+ # publisher.reload!
131
+ #
132
+ def reload!
133
+ ensure_service!
134
+ topic_path = service.topic_path name
135
+ @grpc = service.topic_admin.get_topic topic: topic_path
136
+ @resource_name = nil
137
+ self
138
+ end
139
+
93
140
  ##
94
141
  # Publishes one or more messages to the publisher.
95
142
  #
@@ -166,7 +213,7 @@ module Google
166
213
  #
167
214
  def publish data = nil, attributes = nil, ordering_key: nil, compress: nil, compression_bytes_threshold: nil,
168
215
  **extra_attrs, &block
169
- ensure_service!
216
+ ensure_grpc!
170
217
  batch = BatchPublisher.new data,
171
218
  attributes,
172
219
  ordering_key,
@@ -290,8 +337,7 @@ module Google
290
337
  # publisher.async_publisher.stop!
291
338
  #
292
339
  def publish_async data = nil, attributes = nil, ordering_key: nil, **extra_attrs, &callback
293
- ensure_service!
294
-
340
+ ensure_grpc!
295
341
  @async_publisher ||= AsyncPublisher.new name, service, **@async_opts
296
342
  @async_publisher.publish data, attributes, ordering_key: ordering_key, **extra_attrs, &callback
297
343
  end
@@ -351,6 +397,16 @@ module Google
351
397
  end
352
398
  end
353
399
 
400
+ ##
401
+ # @private New reference {Publisher} from a topic name without making
402
+ # a HTTP request.
403
+ def self.from_name name, service, options = {}
404
+ name = service.topic_path name, options
405
+ from_grpc(nil, service, async: options[:async]).tap do |t|
406
+ t.instance_variable_set :@resource_name, name
407
+ end
408
+ end
409
+
354
410
  protected
355
411
 
356
412
  ##
@@ -364,6 +420,7 @@ module Google
364
420
  # Ensures a Google::Cloud::PubSub::V1::Topic object exists.
365
421
  def ensure_grpc!
366
422
  ensure_service!
423
+ reload! if reference?
367
424
  end
368
425
  end
369
426
  end
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module PubSub
19
- VERSION = "3.0.3".freeze
19
+ VERSION = "3.1.0".freeze
20
20
  end
21
21
 
22
22
  Pubsub = PubSub unless const_defined? :Pubsub
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: 3.0.3
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore