google-cloud-pubsub 1.1.3 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +122 -0
- data/EMULATOR.md +1 -1
- data/TROUBLESHOOTING.md +2 -8
- data/lib/google/cloud/pubsub/async_publisher.rb +15 -19
- data/lib/google/cloud/pubsub/project.rb +18 -26
- data/lib/google/cloud/pubsub/received_message.rb +38 -0
- data/lib/google/cloud/pubsub/retry_policy.rb +90 -0
- data/lib/google/cloud/pubsub/service.rb +37 -15
- data/lib/google/cloud/pubsub/subscriber/inventory.rb +43 -15
- data/lib/google/cloud/pubsub/subscriber/stream.rb +7 -8
- data/lib/google/cloud/pubsub/subscriber.rb +86 -15
- data/lib/google/cloud/pubsub/subscription/push_config.rb +2 -2
- data/lib/google/cloud/pubsub/subscription.rb +296 -6
- data/lib/google/cloud/pubsub/topic.rb +65 -2
- data/lib/google/cloud/pubsub/v1/credentials.rb +1 -1
- data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/iam_policy.rb +1 -1
- data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/options.rb +1 -1
- data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/policy.rb +1 -1
- 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 +168 -79
- data/lib/google/cloud/pubsub/v1/doc/google/type/expr.rb +1 -1
- data/lib/google/cloud/pubsub/v1/publisher_client.rb +175 -33
- data/lib/google/cloud/pubsub/v1/publisher_client_config.json +16 -1
- data/lib/google/cloud/pubsub/v1/subscriber_client.rb +145 -64
- data/lib/google/cloud/pubsub/v1/subscriber_client_config.json +12 -3
- data/lib/google/cloud/pubsub/version.rb +1 -1
- data/lib/google/pubsub/v1/pubsub_pb.rb +20 -0
- data/lib/google/pubsub/v1/pubsub_services_pb.rb +7 -3
- metadata +6 -5
@@ -19,6 +19,7 @@ require "google/cloud/pubsub/async_publisher"
|
|
19
19
|
require "google/cloud/pubsub/batch_publisher"
|
20
20
|
require "google/cloud/pubsub/subscription"
|
21
21
|
require "google/cloud/pubsub/policy"
|
22
|
+
require "google/cloud/pubsub/retry_policy"
|
22
23
|
|
23
24
|
module Google
|
24
25
|
module Cloud
|
@@ -285,6 +286,28 @@ module Google
|
|
285
286
|
# Managing Labels](https://cloud.google.com/pubsub/docs/labels).
|
286
287
|
# @param [Boolean] message_ordering Whether to enable message ordering
|
287
288
|
# on the subscription.
|
289
|
+
# @param [String] filter An expression written in the Cloud Pub/Sub filter language. If non-empty, then only
|
290
|
+
# {Message} instances whose `attributes` field matches the filter are delivered on this subscription. If
|
291
|
+
# empty, then no messages are filtered out. Optional.
|
292
|
+
# @param [Topic] dead_letter_topic The {Topic} to which dead letter messages for the subscription should be
|
293
|
+
# published. Dead lettering is done on a best effort basis. The same message might be dead lettered multiple
|
294
|
+
# times. The Cloud Pub/Sub service account associated with the enclosing subscription's parent project (i.e.,
|
295
|
+
# `service-\\{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com`) must have permission to Publish() to
|
296
|
+
# this topic.
|
297
|
+
#
|
298
|
+
# The operation will fail if the topic does not exist. Users should ensure that there is a subscription
|
299
|
+
# attached to this topic since messages published to a topic with no subscriptions are lost.
|
300
|
+
# @param [Integer] dead_letter_max_delivery_attempts The maximum number of delivery attempts for any message in
|
301
|
+
# the subscription's dead letter policy. Dead lettering is done on a best effort basis. The same message might
|
302
|
+
# be dead lettered multiple times. The value must be between 5 and 100. If this parameter is 0, a default
|
303
|
+
# value of 5 is used. The `dead_letter_topic` must also be set.
|
304
|
+
# @param [RetryPolicy] retry_policy A policy that specifies how Cloud Pub/Sub retries message delivery for
|
305
|
+
# this subscription. If not set, the default retry policy is applied. This generally implies that messages
|
306
|
+
# will be retried as soon as possible for healthy subscribers. Retry Policy will be triggered on NACKs or
|
307
|
+
# acknowledgement deadline exceeded events for a given message.
|
308
|
+
#
|
309
|
+
# **EXPERIMENTAL:** This API might be changed in backward-incompatible ways and is not recommended for
|
310
|
+
# production use. It is not subject to any SLA or deprecation policy.
|
288
311
|
#
|
289
312
|
# @return [Google::Cloud::PubSub::Subscription]
|
290
313
|
#
|
@@ -307,11 +330,51 @@ module Google
|
|
307
330
|
# deadline: 120,
|
308
331
|
# endpoint: "https://example.com/push"
|
309
332
|
#
|
333
|
+
# @example Configure a Dead Letter Queues policy:
|
334
|
+
# require "google/cloud/pubsub"
|
335
|
+
#
|
336
|
+
# pubsub = Google::Cloud::PubSub.new
|
337
|
+
#
|
338
|
+
# # Dead Letter Queue (DLQ) testing requires IAM bindings to the Cloud Pub/Sub service account that is
|
339
|
+
# # automatically created and managed by the service team in a private project.
|
340
|
+
# my_project_number = "000000000000"
|
341
|
+
# service_account_email = "serviceAccount:service-#{my_project_number}@gcp-sa-pubsub.iam.gserviceaccount.com"
|
342
|
+
#
|
343
|
+
# dead_letter_topic = pubsub.topic "my-dead-letter-topic"
|
344
|
+
# dead_letter_subscription = dead_letter_topic.subscribe "my-dead-letter-sub"
|
345
|
+
#
|
346
|
+
# dead_letter_topic.policy { |p| p.add "roles/pubsub.publisher", service_account_email }
|
347
|
+
# dead_letter_subscription.policy { |p| p.add "roles/pubsub.subscriber", service_account_email }
|
348
|
+
#
|
349
|
+
# topic = pubsub.topic "my-topic"
|
350
|
+
# sub = topic.subscribe "my-topic-sub",
|
351
|
+
# dead_letter_topic: dead_letter_topic,
|
352
|
+
# dead_letter_max_delivery_attempts: 10
|
353
|
+
#
|
354
|
+
# @example Configure a Retry Policy:
|
355
|
+
# require "google/cloud/pubsub"
|
356
|
+
#
|
357
|
+
# pubsub = Google::Cloud::PubSub.new
|
358
|
+
#
|
359
|
+
# topic = pubsub.topic "my-topic"
|
360
|
+
#
|
361
|
+
# retry_policy = Google::Cloud::PubSub::RetryPolicy.new minimum_backoff: 5, maximum_backoff: 300
|
362
|
+
# sub = topic.subscribe "my-topic-sub", retry_policy: retry_policy
|
363
|
+
#
|
310
364
|
def subscribe subscription_name, deadline: nil, retain_acked: false, retention: nil, endpoint: nil, labels: nil,
|
311
|
-
message_ordering: nil
|
365
|
+
message_ordering: nil, filter: nil, dead_letter_topic: nil,
|
366
|
+
dead_letter_max_delivery_attempts: nil, retry_policy: nil
|
312
367
|
ensure_service!
|
313
368
|
options = { deadline: deadline, retain_acked: retain_acked, retention: retention, endpoint: endpoint,
|
314
|
-
labels: labels, message_ordering: message_ordering
|
369
|
+
labels: labels, message_ordering: message_ordering, filter: filter,
|
370
|
+
dead_letter_max_delivery_attempts: dead_letter_max_delivery_attempts }
|
371
|
+
|
372
|
+
options[:dead_letter_topic_name] = dead_letter_topic.name if dead_letter_topic
|
373
|
+
if options[:dead_letter_max_delivery_attempts] && !options[:dead_letter_topic_name]
|
374
|
+
# Service error message "3:Invalid resource name given (name=)." does not identify param.
|
375
|
+
raise ArgumentError, "dead_letter_topic is required with dead_letter_max_delivery_attempts"
|
376
|
+
end
|
377
|
+
options[:retry_policy] = retry_policy.to_grpc if retry_policy
|
315
378
|
grpc = service.create_subscription name, subscription_name, options
|
316
379
|
Subscription.from_grpc grpc, service
|
317
380
|
end
|