google-cloud-pubsub 1.9.0 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dfbd62e0e48c406ed08325e5a216f03a0afc4f8319c5ef144fbb6b1fa189e16c
4
- data.tar.gz: 31995baf9d81c17e1c867efb5584da5d0be27e1baa3bfa256311e803d43cbfb9
3
+ metadata.gz: 43ee60087a74bfc9938a61cf66f67b937f30c440f921ef83294f5dd2ec8e1079
4
+ data.tar.gz: 9104bacc161434e7edc1b5553cb0d2f2681ddd6a6a000bf947e212af7dad4df0
5
5
  SHA512:
6
- metadata.gz: 8d50149459ec7bc696a15785ae7f0d77777d9f95edefb4da0775f9e005c25cd8cfe17d20899649fb17c6fc928eb9e0bbc0baddce26afc773d300c54728b04bd6
7
- data.tar.gz: b599664094c01fc88030478e9076ad72a73ceb6bb3aa4b3a64240193694f0d47f6a34bbbd2ab8ce1188c45d6bbd6322d91e91f157362de0a8a6307c002e6084a
6
+ metadata.gz: 4130c4d2961f54b8cf6f1a5957f50d50e37d57bcd56d032df3bbc10497e8788d55e405c69b8570cc24322800af37a35e49daf67755b1652b763b5a9da44b464e
7
+ data.tar.gz: 5777e0c8d1ca9d56c2a94056971b1e59ccf63e3a1e6dd532f5d223f7a6b8a80f0f0aa29bf1aa984376b48d279bccc3e23aa4ff50940c47b4920c47a6340e5975
@@ -1,5 +1,11 @@
1
1
  # Release History
2
2
 
3
+ ### 1.10.0 / 2020-07-23
4
+
5
+ #### Features
6
+
7
+ * Add Subscription#detach and #detached?
8
+
3
9
  ### 1.9.0 / 2020-07-21
4
10
 
5
11
  #### Features
@@ -241,14 +241,13 @@ module Google
241
241
  push_endpoint: options[:endpoint],
242
242
  attributes: (options[:attributes] || {}).to_h
243
243
  end
244
- mrd = Convert.number_to_duration options[:retention]
245
244
  execute do
246
245
  subscriber.create_subscription \
247
246
  name, topic,
248
247
  push_config: push_config,
249
248
  ack_deadline_seconds: options[:deadline],
250
249
  retain_acked_messages: options[:retain_acked],
251
- message_retention_duration: mrd,
250
+ message_retention_duration: Convert.number_to_duration(options[:retention]),
252
251
  labels: options[:labels],
253
252
  enable_message_ordering: options[:message_ordering],
254
253
  filter: options[:filter],
@@ -266,12 +265,20 @@ module Google
266
265
  end
267
266
 
268
267
  ##
269
- # Deletes an existing subscription.
270
- # All pending messages in the subscription are immediately dropped.
268
+ # Deletes an existing subscription. All pending messages in the subscription are immediately dropped.
271
269
  def delete_subscription subscription
272
270
  execute do
273
- subscriber.delete_subscription subscription_path(subscription),
274
- options: default_options
271
+ subscriber.delete_subscription subscription_path(subscription), options: default_options
272
+ end
273
+ end
274
+
275
+ ##
276
+ # Detaches a subscription from its topic. All messages retained in the subscription are dropped. Subsequent
277
+ # `Pull` and `StreamingPull` requests will raise `FAILED_PRECONDITION`. If the subscription is a push
278
+ # subscription, pushes to the endpoint will stop.
279
+ def detach_subscription subscription
280
+ execute do
281
+ publisher.detach_subscription subscription_path(subscription), options: default_options
275
282
  end
276
283
  end
277
284
 
@@ -323,7 +323,7 @@ module Google
323
323
  # If {#expires_in=} is not set, a *default* value of of 31 days will be
324
324
  # used. The minimum allowed value is 1 day.
325
325
  #
326
- # Makes an API call to retrieve the labels value when called on a
326
+ # Makes an API call to retrieve the value when called on a
327
327
  # reference object. See {#reference?}.
328
328
  #
329
329
  # @return [Numeric, nil] The expiration duration, or `nil` if unset.
@@ -566,7 +566,7 @@ module Google
566
566
  #
567
567
  # See {Topic#publish_async}, {#listen}, and {Message#ordering_key}.
568
568
  #
569
- # Makes an API call to retrieve the retain_acked value when called on a
569
+ # Makes an API call to retrieve the enable_message_ordering value when called on a
570
570
  # reference object. See {#reference?}.
571
571
  #
572
572
  # @return [Boolean]
@@ -576,6 +576,35 @@ module Google
576
576
  @grpc.enable_message_ordering
577
577
  end
578
578
 
579
+ ##
580
+ # Whether the subscription is detached from its topic. Detached subscriptions don't receive messages from their
581
+ # topic and don't retain any backlog. {#pull} and {#listen} (pull and streaming pull) operations will raise
582
+ # `FAILED_PRECONDITION`. If the subscription is a push subscription (see {#push_config}), pushes to the endpoint
583
+ # will not be made. The default value is `false`.
584
+ #
585
+ # See {Topic#subscribe} and {#detach}.
586
+ #
587
+ # Makes an API call to retrieve the value when called on a
588
+ # reference object. See {#reference?}.
589
+ #
590
+ # @return [Boolean]
591
+ #
592
+ # @example
593
+ # require "google/cloud/pubsub"
594
+ #
595
+ # pubsub = Google::Cloud::PubSub.new
596
+ #
597
+ # sub = pubsub.subscription "my-topic-sub"
598
+ # sub.detach
599
+ #
600
+ # # sleep 120
601
+ # sub.detached? #=> true
602
+ #
603
+ def detached?
604
+ ensure_grpc!
605
+ @grpc.detached
606
+ end
607
+
579
608
  ##
580
609
  # Determines whether the subscription exists in the Pub/Sub service.
581
610
  #
@@ -623,6 +652,32 @@ module Google
623
652
  true
624
653
  end
625
654
 
655
+ ##
656
+ # Detaches a subscription from its topic. All messages retained in the subscription are dropped. Detached
657
+ # subscriptions don't receive messages from their topic and don't retain any backlog. Subsequent {#pull} and
658
+ # {#listen} (pull and streaming pull) operations will raise `FAILED_PRECONDITION`. If the subscription is a push
659
+ # subscription (see {#push_config}), pushes to the endpoint will stop. It may take a few minutes for the
660
+ # subscription's detached state to be reflected in subsequent calls to {#detached?}.
661
+ #
662
+ # @return [Boolean] Returns `true` if the detach operation was successful.
663
+ #
664
+ # @example
665
+ # require "google/cloud/pubsub"
666
+ #
667
+ # pubsub = Google::Cloud::PubSub.new
668
+ #
669
+ # sub = pubsub.subscription "my-topic-sub"
670
+ # sub.detach
671
+ #
672
+ # # sleep 120
673
+ # sub.detached? #=> true
674
+ #
675
+ def detach
676
+ ensure_service!
677
+ service.detach_subscription name
678
+ true
679
+ end
680
+
626
681
  ##
627
682
  # Pulls messages from the server. Returns an empty list if there are no
628
683
  # messages available in the backlog. Raises an ApiError with status
@@ -368,6 +368,7 @@ module Google
368
368
  options = { deadline: deadline, retain_acked: retain_acked, retention: retention, endpoint: endpoint,
369
369
  labels: labels, message_ordering: message_ordering, filter: filter,
370
370
  dead_letter_max_delivery_attempts: dead_letter_max_delivery_attempts }
371
+
371
372
  options[:dead_letter_topic_name] = dead_letter_topic.name if dead_letter_topic
372
373
  if options[:dead_letter_max_delivery_attempts] && !options[:dead_letter_topic_name]
373
374
  # Service error message "3:Invalid resource name given (name=)." does not identify param.
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module PubSub
19
- VERSION = "1.9.0".freeze
19
+ VERSION = "1.10.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: 1.9.0
4
+ version: 1.10.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: 2020-07-21 00:00:00.000000000 Z
12
+ date: 2020-07-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: concurrent-ruby