google-cloud-pubsub 0.24.0 → 0.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/google/cloud/pubsub.rb +33 -5
- data/lib/google/cloud/pubsub/message.rb +3 -3
- data/lib/google/cloud/pubsub/policy.rb +14 -34
- data/lib/google/cloud/pubsub/project.rb +78 -31
- data/lib/google/cloud/pubsub/service.rb +95 -1
- data/lib/google/cloud/pubsub/snapshot.rb +165 -0
- data/lib/google/cloud/pubsub/snapshot/list.rb +178 -0
- data/lib/google/cloud/pubsub/subscription.rb +155 -34
- data/lib/google/cloud/pubsub/topic.rb +44 -45
- data/lib/google/cloud/pubsub/topic/publisher.rb +3 -3
- data/lib/google/cloud/pubsub/version.rb +1 -1
- metadata +6 -4
@@ -100,6 +100,17 @@ module Google
|
|
100
100
|
# @param [Integer] deadline The maximum number of seconds after a
|
101
101
|
# subscriber receives a message before the subscriber should
|
102
102
|
# acknowledge the message.
|
103
|
+
# @param [Boolean] retain_acked Indicates whether to retain acknowledged
|
104
|
+
# messages. If `true`, then messages are not expunged from the
|
105
|
+
# subscription's backlog, even if they are acknowledged, until they
|
106
|
+
# fall out of the `retention_duration` window. Default is `false`.
|
107
|
+
# @param [Numeric] retention How long to retain unacknowledged messages
|
108
|
+
# in the subscription's backlog, from the moment a message is
|
109
|
+
# published. If `retain_acked` is `true`, then this also configures
|
110
|
+
# the retention of acknowledged messages, and thus configures how far
|
111
|
+
# back in time a {#seek} can be done. Cannot be more than 604,800
|
112
|
+
# seconds (7 days) or less than 600 seconds (10 minutes). Default is
|
113
|
+
# 604,800 seconds (7 days).
|
103
114
|
# @param [String] endpoint A URL locating the endpoint to which messages
|
104
115
|
# should be pushed.
|
105
116
|
#
|
@@ -112,7 +123,7 @@ module Google
|
|
112
123
|
#
|
113
124
|
# topic = pubsub.topic "my-topic"
|
114
125
|
# sub = topic.subscribe "my-topic-sub"
|
115
|
-
#
|
126
|
+
# sub.name # => "my-topic-sub"
|
116
127
|
#
|
117
128
|
# @example Wait 2 minutes for acknowledgement and push all to endpoint:
|
118
129
|
# require "google/cloud/pubsub"
|
@@ -124,9 +135,11 @@ module Google
|
|
124
135
|
# deadline: 120,
|
125
136
|
# endpoint: "https://example.com/push"
|
126
137
|
#
|
127
|
-
def subscribe subscription_name, deadline: nil,
|
138
|
+
def subscribe subscription_name, deadline: nil, retain_acked: false,
|
139
|
+
retention: nil, endpoint: nil
|
128
140
|
ensure_service!
|
129
|
-
options = { deadline: deadline,
|
141
|
+
options = { deadline: deadline, retain_acked: retain_acked,
|
142
|
+
retention: retention, endpoint: endpoint }
|
130
143
|
grpc = service.create_subscription name, subscription_name, options
|
131
144
|
Subscription.from_grpc grpc, service
|
132
145
|
end
|
@@ -151,17 +164,20 @@ module Google
|
|
151
164
|
# pubsub = Google::Cloud::Pubsub.new
|
152
165
|
#
|
153
166
|
# topic = pubsub.topic "my-topic"
|
154
|
-
#
|
155
|
-
#
|
167
|
+
#
|
168
|
+
# sub = topic.subscription "my-topic-sub"
|
169
|
+
# sub.name #=> "projects/my-project/subscriptions/my-topic-sub"
|
156
170
|
#
|
157
171
|
# @example Skip the lookup against the service with `skip_lookup`:
|
158
172
|
# require "google/cloud/pubsub"
|
159
173
|
#
|
160
174
|
# pubsub = Google::Cloud::Pubsub.new
|
161
175
|
#
|
176
|
+
# topic = pubsub.topic "my-topic"
|
177
|
+
#
|
162
178
|
# # No API call is made to retrieve the subscription information.
|
163
|
-
#
|
164
|
-
#
|
179
|
+
# sub = topic.subscription "my-topic-sub", skip_lookup: true
|
180
|
+
# sub.name #=> "projects/my-project/subscriptions/my-topic-sub"
|
165
181
|
#
|
166
182
|
def subscription subscription_name, skip_lookup: nil
|
167
183
|
ensure_service!
|
@@ -190,7 +206,7 @@ module Google
|
|
190
206
|
# pubsub = Google::Cloud::Pubsub.new
|
191
207
|
#
|
192
208
|
# topic = pubsub.topic "my-topic"
|
193
|
-
#
|
209
|
+
# subscriptions = topic.subscriptions
|
194
210
|
# subscriptions.each do |subscription|
|
195
211
|
# puts subscription.name
|
196
212
|
# end
|
@@ -201,7 +217,7 @@ module Google
|
|
201
217
|
# pubsub = Google::Cloud::Pubsub.new
|
202
218
|
#
|
203
219
|
# topic = pubsub.topic "my-topic"
|
204
|
-
#
|
220
|
+
# subscriptions = topic.subscriptions
|
205
221
|
# subscriptions.all do |subscription|
|
206
222
|
# puts subscription.name
|
207
223
|
# end
|
@@ -234,7 +250,7 @@ module Google
|
|
234
250
|
# pubsub = Google::Cloud::Pubsub.new
|
235
251
|
#
|
236
252
|
# topic = pubsub.topic "my-topic"
|
237
|
-
# msg = topic.publish "
|
253
|
+
# msg = topic.publish "task completed"
|
238
254
|
#
|
239
255
|
# @example A message can be published using a File object:
|
240
256
|
# require "google/cloud/pubsub"
|
@@ -250,7 +266,7 @@ module Google
|
|
250
266
|
# pubsub = Google::Cloud::Pubsub.new
|
251
267
|
#
|
252
268
|
# topic = pubsub.topic "my-topic"
|
253
|
-
# msg = topic.publish "
|
269
|
+
# msg = topic.publish "task completed",
|
254
270
|
# foo: :bar,
|
255
271
|
# this: :that
|
256
272
|
#
|
@@ -261,9 +277,9 @@ module Google
|
|
261
277
|
#
|
262
278
|
# topic = pubsub.topic "my-topic"
|
263
279
|
# msgs = topic.publish do |t|
|
264
|
-
# t.publish "
|
265
|
-
# t.publish "
|
266
|
-
# t.publish "
|
280
|
+
# t.publish "task 1 completed", foo: :bar
|
281
|
+
# t.publish "task 2 completed", foo: :baz
|
282
|
+
# t.publish "task 3 completed", foo: :bif
|
267
283
|
# end
|
268
284
|
#
|
269
285
|
def publish data = nil, attributes = {}
|
@@ -281,11 +297,6 @@ module Google
|
|
281
297
|
# @see https://cloud.google.com/pubsub/docs/reference/rpc/google.iam.v1#iampolicy
|
282
298
|
# google.iam.v1.IAMPolicy
|
283
299
|
#
|
284
|
-
# @param [Boolean] force Force the latest policy to be retrieved from
|
285
|
-
# the Pub/Sub service when `true`. Otherwise the policy will be
|
286
|
-
# memoized to reduce the number of API calls made to the Pub/Sub
|
287
|
-
# service. The default is `false`.
|
288
|
-
#
|
289
300
|
# @yield [policy] A block for updating the policy. The latest policy
|
290
301
|
# will be read from the Pub/Sub service and passed to the block. After
|
291
302
|
# the block completes, the modified policy will be written to the
|
@@ -295,23 +306,13 @@ module Google
|
|
295
306
|
#
|
296
307
|
# @return [Policy] the current Cloud IAM Policy for this topic
|
297
308
|
#
|
298
|
-
# @example
|
299
|
-
# require "google/cloud/pubsub"
|
300
|
-
#
|
301
|
-
# pubsub = Google::Cloud::Pubsub.new
|
302
|
-
# topic = pubsub.topic "my-topic"
|
303
|
-
#
|
304
|
-
# policy = topic.policy # API call
|
305
|
-
# policy_2 = topic.policy # No API call
|
306
|
-
#
|
307
|
-
# @example Use `force` to retrieve the latest policy from the service:
|
309
|
+
# @example
|
308
310
|
# require "google/cloud/pubsub"
|
309
311
|
#
|
310
312
|
# pubsub = Google::Cloud::Pubsub.new
|
311
313
|
# topic = pubsub.topic "my-topic"
|
312
314
|
#
|
313
|
-
# policy = topic.policy
|
314
|
-
# policy_2 = topic.policy force: true # API call
|
315
|
+
# policy = topic.policy
|
315
316
|
#
|
316
317
|
# @example Update the policy by passing a block:
|
317
318
|
# require "google/cloud/pubsub"
|
@@ -319,21 +320,17 @@ module Google
|
|
319
320
|
# pubsub = Google::Cloud::Pubsub.new
|
320
321
|
# topic = pubsub.topic "my-topic"
|
321
322
|
#
|
322
|
-
#
|
323
|
+
# topic.policy do |p|
|
323
324
|
# p.add "roles/owner", "user:owner@example.com"
|
324
|
-
# end
|
325
|
-
#
|
326
|
-
def policy
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
return @policy unless block_given?
|
334
|
-
p = @policy.deep_dup
|
335
|
-
yield p
|
336
|
-
self.policy = p
|
325
|
+
# end
|
326
|
+
#
|
327
|
+
def policy
|
328
|
+
ensure_service!
|
329
|
+
grpc = service.get_topic_policy name
|
330
|
+
policy = Policy.from_grpc grpc
|
331
|
+
return policy unless block_given?
|
332
|
+
yield policy
|
333
|
+
self.policy = policy
|
337
334
|
end
|
338
335
|
|
339
336
|
##
|
@@ -351,6 +348,8 @@ module Google
|
|
351
348
|
# @param [Policy] new_policy a new or modified Cloud IAM Policy for this
|
352
349
|
# topic
|
353
350
|
#
|
351
|
+
# @return [Policy] the policy returned by the API update operation
|
352
|
+
#
|
354
353
|
# @example
|
355
354
|
# require "google/cloud/pubsub"
|
356
355
|
#
|
@@ -27,9 +27,9 @@ module Google
|
|
27
27
|
#
|
28
28
|
# topic = pubsub.topic "my-topic"
|
29
29
|
# msgs = topic.publish do |t|
|
30
|
-
# t.publish "
|
31
|
-
# t.publish "
|
32
|
-
# t.publish "
|
30
|
+
# t.publish "task 1 completed", foo: :bar
|
31
|
+
# t.publish "task 2 completed", foo: :baz
|
32
|
+
# t.publish "task 3 completed", foo: :bif
|
33
33
|
# end
|
34
34
|
class Publisher
|
35
35
|
##
|
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: 0.
|
4
|
+
version: 0.25.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Moore
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-06-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-cloud-core
|
@@ -198,6 +198,8 @@ files:
|
|
198
198
|
- lib/google/cloud/pubsub/project.rb
|
199
199
|
- lib/google/cloud/pubsub/received_message.rb
|
200
200
|
- lib/google/cloud/pubsub/service.rb
|
201
|
+
- lib/google/cloud/pubsub/snapshot.rb
|
202
|
+
- lib/google/cloud/pubsub/snapshot/list.rb
|
201
203
|
- lib/google/cloud/pubsub/subscription.rb
|
202
204
|
- lib/google/cloud/pubsub/subscription/list.rb
|
203
205
|
- lib/google/cloud/pubsub/topic.rb
|
@@ -215,7 +217,7 @@ files:
|
|
215
217
|
- lib/google/cloud/pubsub/version.rb
|
216
218
|
- lib/google/pubsub/v1/pubsub_pb.rb
|
217
219
|
- lib/google/pubsub/v1/pubsub_services_pb.rb
|
218
|
-
homepage:
|
220
|
+
homepage: https://github.com/GoogleCloudPlatform/google-cloud-ruby/tree/master/google-cloud-pubsub
|
219
221
|
licenses:
|
220
222
|
- Apache-2.0
|
221
223
|
metadata: {}
|
@@ -235,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
235
237
|
version: '0'
|
236
238
|
requirements: []
|
237
239
|
rubyforge_project:
|
238
|
-
rubygems_version: 2.6.
|
240
|
+
rubygems_version: 2.6.12
|
239
241
|
signing_key:
|
240
242
|
specification_version: 4
|
241
243
|
summary: API Client library for Google Cloud Pub/Sub
|