google-cloud-pubsub 1.6.1 → 1.10.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 +4 -4
- data/CHANGELOG.md +35 -0
- data/TROUBLESHOOTING.md +2 -8
- data/lib/google/cloud/pubsub/retry_policy.rb +90 -0
- data/lib/google/cloud/pubsub/service.rb +27 -14
- data/lib/google/cloud/pubsub/subscriber/stream.rb +3 -0
- data/lib/google/cloud/pubsub/subscription.rb +129 -2
- data/lib/google/cloud/pubsub/topic.rb +26 -2
- data/lib/google/cloud/pubsub/v1/doc/google/pubsub/v1/pubsub.rb +54 -17
- data/lib/google/cloud/pubsub/v1/publisher_client.rb +60 -1
- data/lib/google/cloud/pubsub/v1/publisher_client_config.json +6 -0
- data/lib/google/cloud/pubsub/v1/subscriber_client.rb +12 -9
- data/lib/google/cloud/pubsub/version.rb +1 -1
- data/lib/google/pubsub/v1/pubsub_pb.rb +10 -0
- data/lib/google/pubsub/v1/pubsub_services_pb.rb +6 -1
- metadata +4 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 43ee60087a74bfc9938a61cf66f67b937f30c440f921ef83294f5dd2ec8e1079
         | 
| 4 | 
            +
              data.tar.gz: 9104bacc161434e7edc1b5553cb0d2f2681ddd6a6a000bf947e212af7dad4df0
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 4130c4d2961f54b8cf6f1a5957f50d50e37d57bcd56d032df3bbc10497e8788d55e405c69b8570cc24322800af37a35e49daf67755b1652b763b5a9da44b464e
         | 
| 7 | 
            +
              data.tar.gz: 5777e0c8d1ca9d56c2a94056971b1e59ccf63e3a1e6dd532f5d223f7a6b8a80f0f0aa29bf1aa984376b48d279bccc3e23aa4ff50940c47b4920c47a6340e5975
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,5 +1,40 @@ | |
| 1 1 | 
             
            # Release History
         | 
| 2 2 |  | 
| 3 | 
            +
            ### 1.10.0 / 2020-07-23
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            #### Features
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            * Add Subscription#detach and #detached?
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            ### 1.9.0 / 2020-07-21
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            #### Features
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            * Add support for server-side flow control
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            ### 1.8.0 / 2020-06-29
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            #### Features
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            * Add Subscription#filter
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            ### 1.7.1 / 2020-05-28
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            #### Documentation
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            * Fix a few broken links
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            ### 1.7.0 / 2020-05-21
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            #### Features
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            * Add Retry Policy support
         | 
| 32 | 
            +
              * Add RetryPolicy
         | 
| 33 | 
            +
              * Add retry_policy param to Topic#subscribe
         | 
| 34 | 
            +
              * Add Subscription#retry_policy
         | 
| 35 | 
            +
              * Add Subscription#retry_policy=
         | 
| 36 | 
            +
            * Set client-scoped UUID in initial StreamingPullRequest#client_id
         | 
| 37 | 
            +
             | 
| 3 38 | 
             
            ### 1.6.1 / 2020-05-06
         | 
| 4 39 |  | 
| 5 40 | 
             
            #### Documentation
         | 
    
        data/TROUBLESHOOTING.md
    CHANGED
    
    | @@ -24,14 +24,8 @@ improved, *please* create a new issue on GitHub so we can talk about it. | |
| 24 24 |  | 
| 25 25 | 
             
              - [New issue][gh-ruby]
         | 
| 26 26 |  | 
| 27 | 
            -
            Or, you can ask questions on the [Google Cloud Platform Slack][slack-ruby]. You
         | 
| 28 | 
            -
            can use the "ruby" channel for general Ruby questions, or use the
         | 
| 29 | 
            -
            "google-cloud-ruby" channel if you have questions about this gem in particular.
         | 
| 30 | 
            -
             | 
| 31 27 | 
             
            [so-ruby]: http://stackoverflow.com/questions/tagged/google-cloud-platform+ruby+pubsub
         | 
| 32 28 |  | 
| 33 | 
            -
            [gh-search-ruby]: https://github.com/ | 
| 34 | 
            -
             | 
| 35 | 
            -
            [gh-ruby]: https://github.com/googlecloudplatform/google-cloud-ruby/issues/new
         | 
| 29 | 
            +
            [gh-search-ruby]: https://github.com/googleapis/google-cloud-ruby/issues?q=label%3A%22api%3A+pubsub%22
         | 
| 36 30 |  | 
| 37 | 
            -
            [ | 
| 31 | 
            +
            [gh-ruby]: https://github.com/googleapis/google-cloud-ruby/issues/new
         | 
| @@ -0,0 +1,90 @@ | |
| 1 | 
            +
            # Copyright 2016 Google LLC
         | 
| 2 | 
            +
            #
         | 
| 3 | 
            +
            # Licensed under the Apache License, Version 2.0 (the "License");
         | 
| 4 | 
            +
            # you may not use this file except in compliance with the License.
         | 
| 5 | 
            +
            # You may obtain a copy of the License at
         | 
| 6 | 
            +
            #
         | 
| 7 | 
            +
            #     https://www.apache.org/licenses/LICENSE-2.0
         | 
| 8 | 
            +
            #
         | 
| 9 | 
            +
            # Unless required by applicable law or agreed to in writing, software
         | 
| 10 | 
            +
            # distributed under the License is distributed on an "AS IS" BASIS,
         | 
| 11 | 
            +
            # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         | 
| 12 | 
            +
            # See the License for the specific language governing permissions and
         | 
| 13 | 
            +
            # limitations under the License.
         | 
| 14 | 
            +
             | 
| 15 | 
            +
             | 
| 16 | 
            +
            require "google/cloud/errors"
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            module Google
         | 
| 19 | 
            +
              module Cloud
         | 
| 20 | 
            +
                module PubSub
         | 
| 21 | 
            +
                  ##
         | 
| 22 | 
            +
                  # # RetryPolicy
         | 
| 23 | 
            +
                  #
         | 
| 24 | 
            +
                  # An immutable Retry Policy value object that specifies how Cloud Pub/Sub retries message delivery.
         | 
| 25 | 
            +
                  #
         | 
| 26 | 
            +
                  # Retry delay will be exponential based on provided minimum and maximum backoffs. (See [Exponential
         | 
| 27 | 
            +
                  # backoff](https://en.wikipedia.org/wiki/Exponential_backoff).)
         | 
| 28 | 
            +
                  #
         | 
| 29 | 
            +
                  # Retry Policy will be triggered on NACKs or acknowledgement deadline exceeded events for a given message.
         | 
| 30 | 
            +
                  #
         | 
| 31 | 
            +
                  # Retry Policy is implemented on a best effort basis. At times, the delay between consecutive deliveries may not
         | 
| 32 | 
            +
                  # match the configuration. That is, delay can be more or less than configured backoff.
         | 
| 33 | 
            +
                  #
         | 
| 34 | 
            +
                  # **EXPERIMENTAL:** This API might be changed in backward-incompatible ways and is not recommended for production
         | 
| 35 | 
            +
                  # use. It is not subject to any SLA or deprecation policy.
         | 
| 36 | 
            +
                  #
         | 
| 37 | 
            +
                  # @attr [Numeric] minimum_backoff The minimum delay between consecutive deliveries of a given message. Value
         | 
| 38 | 
            +
                  #   should be between 0 and 600 seconds. The default value is 10 seconds.
         | 
| 39 | 
            +
                  # @attr [Numeric] maximum_backoff The maximum delay between consecutive deliveries of a given message. Value
         | 
| 40 | 
            +
                  #   should be between 0 and 600 seconds. The default value is 600 seconds.
         | 
| 41 | 
            +
                  #
         | 
| 42 | 
            +
                  # @example
         | 
| 43 | 
            +
                  #   require "google/cloud/pubsub"
         | 
| 44 | 
            +
                  #
         | 
| 45 | 
            +
                  #   pubsub = Google::Cloud::PubSub.new
         | 
| 46 | 
            +
                  #
         | 
| 47 | 
            +
                  #   sub = pubsub.subscription "my-topic-sub"
         | 
| 48 | 
            +
                  #
         | 
| 49 | 
            +
                  #   sub.retry_policy = Google::Cloud::PubSub::RetryPolicy.new minimum_backoff: 5, maximum_backoff: 300
         | 
| 50 | 
            +
                  #
         | 
| 51 | 
            +
                  #   sub.retry_policy.minimum_backoff #=> 5
         | 
| 52 | 
            +
                  #   sub.retry_policy.maximum_backoff #=> 300
         | 
| 53 | 
            +
                  #
         | 
| 54 | 
            +
                  class RetryPolicy
         | 
| 55 | 
            +
                    attr_reader :minimum_backoff, :maximum_backoff
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                    ##
         | 
| 58 | 
            +
                    # Creates a new, immutable RetryPolicy value object.
         | 
| 59 | 
            +
                    #
         | 
| 60 | 
            +
                    # @attr [Numeric, nil] minimum_backoff The minimum delay between consecutive deliveries of a given message.
         | 
| 61 | 
            +
                    #   Value should be between 0 and 600 seconds. If `nil` is provided, the default value is 10 seconds.
         | 
| 62 | 
            +
                    # @attr [Numeric, nil] maximum_backoff The maximum delay between consecutive deliveries of a given message.
         | 
| 63 | 
            +
                    #   Value should be between 0 and 600 seconds. If `nil` is provided, the default value is 600 seconds.
         | 
| 64 | 
            +
                    #
         | 
| 65 | 
            +
                    def initialize minimum_backoff: nil, maximum_backoff: nil
         | 
| 66 | 
            +
                      @minimum_backoff = minimum_backoff
         | 
| 67 | 
            +
                      @maximum_backoff = maximum_backoff
         | 
| 68 | 
            +
                    end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                    ##
         | 
| 71 | 
            +
                    # @private Convert the RetryPolicy to a Google::Cloud::PubSub::V1::RetryPolicy object.
         | 
| 72 | 
            +
                    def to_grpc
         | 
| 73 | 
            +
                      Google::Cloud::PubSub::V1::RetryPolicy.new(
         | 
| 74 | 
            +
                        minimum_backoff: Convert.number_to_duration(minimum_backoff),
         | 
| 75 | 
            +
                        maximum_backoff: Convert.number_to_duration(maximum_backoff)
         | 
| 76 | 
            +
                      )
         | 
| 77 | 
            +
                    end
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                    ##
         | 
| 80 | 
            +
                    # @private New RetryPolicy from a Google::Cloud::PubSub::V1::RetryPolicy object.
         | 
| 81 | 
            +
                    def self.from_grpc grpc
         | 
| 82 | 
            +
                      new(
         | 
| 83 | 
            +
                        minimum_backoff: Convert.duration_to_number(grpc.minimum_backoff),
         | 
| 84 | 
            +
                        maximum_backoff: Convert.duration_to_number(grpc.maximum_backoff)
         | 
| 85 | 
            +
                      )
         | 
| 86 | 
            +
                    end
         | 
| 87 | 
            +
                  end
         | 
| 88 | 
            +
                end
         | 
| 89 | 
            +
              end
         | 
| 90 | 
            +
            end
         | 
| @@ -19,6 +19,7 @@ require "google/cloud/pubsub/convert" | |
| 19 19 | 
             
            require "google/cloud/pubsub/version"
         | 
| 20 20 | 
             
            require "google/cloud/pubsub/v1"
         | 
| 21 21 | 
             
            require "google/gax/errors"
         | 
| 22 | 
            +
            require "securerandom"
         | 
| 22 23 |  | 
| 23 24 | 
             
            module Google
         | 
| 24 25 | 
             
              module Cloud
         | 
| @@ -28,6 +29,12 @@ module Google | |
| 28 29 | 
             
                  # methods.
         | 
| 29 30 | 
             
                  class Service
         | 
| 30 31 | 
             
                    attr_accessor :project, :credentials, :host, :timeout, :client_config
         | 
| 32 | 
            +
                    ###
         | 
| 33 | 
            +
                    # The same client_id is used across all streaming pull connections that are created by this client. This is
         | 
| 34 | 
            +
                    # intentional, as it indicates to the server that any guarantees, such as message ordering, made for a stream
         | 
| 35 | 
            +
                    # that is disconnected will be made for the stream that is created to replace it. The attr_accessor allows the
         | 
| 36 | 
            +
                    # value to be replaced for unit testing.
         | 
| 37 | 
            +
                    attr_accessor :client_id
         | 
| 31 38 |  | 
| 32 39 | 
             
                    ##
         | 
| 33 40 | 
             
                    # Creates a new Service instance.
         | 
| @@ -38,6 +45,7 @@ module Google | |
| 38 45 | 
             
                      @host = host || V1::PublisherClient::SERVICE_ADDRESS
         | 
| 39 46 | 
             
                      @timeout = timeout
         | 
| 40 47 | 
             
                      @client_config = client_config || {}
         | 
| 48 | 
            +
                      @client_id = SecureRandom.uuid.freeze
         | 
| 41 49 | 
             
                    end
         | 
| 42 50 |  | 
| 43 51 | 
             
                    def channel
         | 
| @@ -233,21 +241,18 @@ module Google | |
| 233 241 | 
             
                                        push_endpoint: options[:endpoint],
         | 
| 234 242 | 
             
                                        attributes:    (options[:attributes] || {}).to_h
         | 
| 235 243 | 
             
                                    end
         | 
| 236 | 
            -
                      deadline = options[:deadline]
         | 
| 237 | 
            -
                      retain_acked = options[:retain_acked]
         | 
| 238 | 
            -
                      mrd = Convert.number_to_duration options[:retention]
         | 
| 239 | 
            -
                      labels = options[:labels]
         | 
| 240 | 
            -
                      message_ordering = options[:message_ordering]
         | 
| 241 244 | 
             
                      execute do
         | 
| 242 245 | 
             
                        subscriber.create_subscription \
         | 
| 243 246 | 
             
                          name, topic,
         | 
| 244 247 | 
             
                          push_config:                push_config,
         | 
| 245 | 
            -
                          ack_deadline_seconds:       deadline,
         | 
| 246 | 
            -
                          retain_acked_messages:      retain_acked,
         | 
| 247 | 
            -
                          message_retention_duration:  | 
| 248 | 
            -
                          labels:                     labels,
         | 
| 249 | 
            -
                          enable_message_ordering:    message_ordering,
         | 
| 248 | 
            +
                          ack_deadline_seconds:       options[:deadline],
         | 
| 249 | 
            +
                          retain_acked_messages:      options[:retain_acked],
         | 
| 250 | 
            +
                          message_retention_duration: Convert.number_to_duration(options[:retention]),
         | 
| 251 | 
            +
                          labels:                     options[:labels],
         | 
| 252 | 
            +
                          enable_message_ordering:    options[:message_ordering],
         | 
| 253 | 
            +
                          filter:                     options[:filter],
         | 
| 250 254 | 
             
                          dead_letter_policy:         dead_letter_policy(options),
         | 
| 255 | 
            +
                          retry_policy:               options[:retry_policy],
         | 
| 251 256 | 
             
                          options:                    default_options
         | 
| 252 257 | 
             
                      end
         | 
| 253 258 | 
             
                    end
         | 
| @@ -260,12 +265,20 @@ module Google | |
| 260 265 | 
             
                    end
         | 
| 261 266 |  | 
| 262 267 | 
             
                    ##
         | 
| 263 | 
            -
                    # Deletes an existing subscription.
         | 
| 264 | 
            -
                    # All pending messages in the subscription are immediately dropped.
         | 
| 268 | 
            +
                    # Deletes an existing subscription. All pending messages in the subscription are immediately dropped.
         | 
| 265 269 | 
             
                    def delete_subscription subscription
         | 
| 266 270 | 
             
                      execute do
         | 
| 267 | 
            -
                        subscriber.delete_subscription subscription_path(subscription),
         | 
| 268 | 
            -
             | 
| 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
         | 
| 269 282 | 
             
                      end
         | 
| 270 283 | 
             
                    end
         | 
| 271 284 |  | 
| @@ -363,6 +363,9 @@ module Google | |
| 363 363 | 
             
                          req.stream_ack_deadline_seconds = @subscriber.deadline
         | 
| 364 364 | 
             
                          req.modify_deadline_ack_ids += @inventory.ack_ids
         | 
| 365 365 | 
             
                          req.modify_deadline_seconds += @inventory.ack_ids.map { @subscriber.deadline }
         | 
| 366 | 
            +
                          req.client_id = @subscriber.service.client_id
         | 
| 367 | 
            +
                          req.max_outstanding_messages = @inventory.limit
         | 
| 368 | 
            +
                          req.max_outstanding_bytes = @inventory.bytesize
         | 
| 366 369 | 
             
                        end
         | 
| 367 370 | 
             
                      end
         | 
| 368 371 |  | 
| @@ -18,6 +18,7 @@ require "google/cloud/errors" | |
| 18 18 | 
             
            require "google/cloud/pubsub/subscription/list"
         | 
| 19 19 | 
             
            require "google/cloud/pubsub/subscription/push_config"
         | 
| 20 20 | 
             
            require "google/cloud/pubsub/received_message"
         | 
| 21 | 
            +
            require "google/cloud/pubsub/retry_policy"
         | 
| 21 22 | 
             
            require "google/cloud/pubsub/snapshot"
         | 
| 22 23 | 
             
            require "google/cloud/pubsub/subscriber"
         | 
| 23 24 | 
             
            require "google/cloud/pubsub/v1"
         | 
| @@ -322,7 +323,7 @@ module Google | |
| 322 323 | 
             
                    # If {#expires_in=} is not set, a *default* value of of 31 days will be
         | 
| 323 324 | 
             
                    # used. The minimum allowed value is 1 day.
         | 
| 324 325 | 
             
                    #
         | 
| 325 | 
            -
                    # Makes an API call to retrieve the  | 
| 326 | 
            +
                    # Makes an API call to retrieve the value when called on a
         | 
| 326 327 | 
             
                    # reference object. See {#reference?}.
         | 
| 327 328 | 
             
                    #
         | 
| 328 329 | 
             
                    # @return [Numeric, nil] The expiration duration, or `nil` if unset.
         | 
| @@ -352,6 +353,18 @@ module Google | |
| 352 353 | 
             
                      @resource_name = nil
         | 
| 353 354 | 
             
                    end
         | 
| 354 355 |  | 
| 356 | 
            +
                    ##
         | 
| 357 | 
            +
                    # An expression written in the Cloud Pub/Sub filter language. If non-empty, then only {Message} instances whose
         | 
| 358 | 
            +
                    # `attributes` field matches the filter are delivered on this subscription. If empty, then no messages are
         | 
| 359 | 
            +
                    # filtered out.
         | 
| 360 | 
            +
                    #
         | 
| 361 | 
            +
                    # @return [String] The frozen filter string.
         | 
| 362 | 
            +
                    #
         | 
| 363 | 
            +
                    def filter
         | 
| 364 | 
            +
                      ensure_grpc!
         | 
| 365 | 
            +
                      @grpc.filter.freeze
         | 
| 366 | 
            +
                    end
         | 
| 367 | 
            +
             | 
| 355 368 | 
             
                    ##
         | 
| 356 369 | 
             
                    # Returns the {Topic} to which dead letter messages should be published if a dead letter policy is configured,
         | 
| 357 370 | 
             
                    # otherwise `nil`. Dead lettering is done on a best effort basis. The same message might be dead lettered
         | 
| @@ -483,6 +496,65 @@ module Google | |
| 483 496 | 
             
                      @resource_name = nil
         | 
| 484 497 | 
             
                    end
         | 
| 485 498 |  | 
| 499 | 
            +
                    ##
         | 
| 500 | 
            +
                    # A policy that specifies how Cloud Pub/Sub retries message delivery for this subscription. If `nil`, the
         | 
| 501 | 
            +
                    # default retry policy is applied. This generally implies that messages will be retried as soon as possible
         | 
| 502 | 
            +
                    # for healthy subscribers. Retry Policy will be triggered on NACKs or acknowledgement deadline exceeded events
         | 
| 503 | 
            +
                    # for a given message.
         | 
| 504 | 
            +
                    #
         | 
| 505 | 
            +
                    # **EXPERIMENTAL:** This API might be changed in backward-incompatible ways and is not recommended for
         | 
| 506 | 
            +
                    # production use. It is not subject to any SLA or deprecation policy.
         | 
| 507 | 
            +
                    #
         | 
| 508 | 
            +
                    # @return [RetryPolicy, nil] The retry policy for the subscription, or `nil`.
         | 
| 509 | 
            +
                    #
         | 
| 510 | 
            +
                    # @example
         | 
| 511 | 
            +
                    #   require "google/cloud/pubsub"
         | 
| 512 | 
            +
                    #
         | 
| 513 | 
            +
                    #   pubsub = Google::Cloud::PubSub.new
         | 
| 514 | 
            +
                    #
         | 
| 515 | 
            +
                    #   sub = pubsub.subscription "my-topic-sub"
         | 
| 516 | 
            +
                    #
         | 
| 517 | 
            +
                    #   sub.retry_policy = Google::Cloud::PubSub::RetryPolicy.new minimum_backoff: 5, maximum_backoff: 300
         | 
| 518 | 
            +
                    #
         | 
| 519 | 
            +
                    #   sub.retry_policy.minimum_backoff #=> 5
         | 
| 520 | 
            +
                    #   sub.retry_policy.maximum_backoff #=> 300
         | 
| 521 | 
            +
                    #
         | 
| 522 | 
            +
                    def retry_policy
         | 
| 523 | 
            +
                      ensure_grpc!
         | 
| 524 | 
            +
                      return nil unless @grpc.retry_policy
         | 
| 525 | 
            +
                      RetryPolicy.from_grpc @grpc.retry_policy
         | 
| 526 | 
            +
                    end
         | 
| 527 | 
            +
             | 
| 528 | 
            +
                    ##
         | 
| 529 | 
            +
                    # Sets a policy that specifies how Cloud Pub/Sub retries message delivery for this subscription. If `nil`, the
         | 
| 530 | 
            +
                    # default retry policy is applied. This generally implies that messages will be retried as soon as possible
         | 
| 531 | 
            +
                    # for healthy subscribers. Retry Policy will be triggered on NACKs or acknowledgement deadline exceeded events
         | 
| 532 | 
            +
                    # for a given message.
         | 
| 533 | 
            +
                    #
         | 
| 534 | 
            +
                    # **EXPERIMENTAL:** This API might be changed in backward-incompatible ways and is not recommended for
         | 
| 535 | 
            +
                    # production use. It is not subject to any SLA or deprecation policy.
         | 
| 536 | 
            +
                    #
         | 
| 537 | 
            +
                    # @param [RetryPolicy, nil] new_retry_policy A new retry policy for the subscription, or `nil`.
         | 
| 538 | 
            +
                    #
         | 
| 539 | 
            +
                    # @example
         | 
| 540 | 
            +
                    #   require "google/cloud/pubsub"
         | 
| 541 | 
            +
                    #
         | 
| 542 | 
            +
                    #   pubsub = Google::Cloud::PubSub.new
         | 
| 543 | 
            +
                    #
         | 
| 544 | 
            +
                    #   sub = pubsub.subscription "my-topic-sub"
         | 
| 545 | 
            +
                    #
         | 
| 546 | 
            +
                    #   sub.retry_policy = Google::Cloud::PubSub::RetryPolicy.new minimum_backoff: 5, maximum_backoff: 300
         | 
| 547 | 
            +
                    #
         | 
| 548 | 
            +
                    #   sub.retry_policy.minimum_backoff #=> 5
         | 
| 549 | 
            +
                    #   sub.retry_policy.maximum_backoff #=> 300
         | 
| 550 | 
            +
                    #
         | 
| 551 | 
            +
                    def retry_policy= new_retry_policy
         | 
| 552 | 
            +
                      ensure_grpc!
         | 
| 553 | 
            +
                      new_retry_policy = new_retry_policy.to_grpc if new_retry_policy
         | 
| 554 | 
            +
                      update_grpc = Google::Cloud::PubSub::V1::Subscription.new name: name, retry_policy: new_retry_policy
         | 
| 555 | 
            +
                      @grpc = service.update_subscription update_grpc, :retry_policy
         | 
| 556 | 
            +
                    end
         | 
| 557 | 
            +
             | 
| 486 558 | 
             
                    ##
         | 
| 487 559 | 
             
                    # Whether message ordering has been enabled. When enabled, messages
         | 
| 488 560 | 
             
                    # published with the same `ordering_key` will be delivered in the order
         | 
| @@ -494,7 +566,7 @@ module Google | |
| 494 566 | 
             
                    #
         | 
| 495 567 | 
             
                    # See {Topic#publish_async}, {#listen}, and {Message#ordering_key}.
         | 
| 496 568 | 
             
                    #
         | 
| 497 | 
            -
                    # Makes an API call to retrieve the  | 
| 569 | 
            +
                    # Makes an API call to retrieve the enable_message_ordering value when called on a
         | 
| 498 570 | 
             
                    # reference object. See {#reference?}.
         | 
| 499 571 | 
             
                    #
         | 
| 500 572 | 
             
                    # @return [Boolean]
         | 
| @@ -504,6 +576,35 @@ module Google | |
| 504 576 | 
             
                      @grpc.enable_message_ordering
         | 
| 505 577 | 
             
                    end
         | 
| 506 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 | 
            +
             | 
| 507 608 | 
             
                    ##
         | 
| 508 609 | 
             
                    # Determines whether the subscription exists in the Pub/Sub service.
         | 
| 509 610 | 
             
                    #
         | 
| @@ -551,6 +652,32 @@ module Google | |
| 551 652 | 
             
                      true
         | 
| 552 653 | 
             
                    end
         | 
| 553 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 | 
            +
             | 
| 554 681 | 
             
                    ##
         | 
| 555 682 | 
             
                    # Pulls messages from the server. Returns an empty list if there are no
         | 
| 556 683 | 
             
                    # messages available in the backlog. Raises an ApiError with status
         | 
| @@ -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,9 @@ 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.
         | 
| 288 292 | 
             
                    # @param [Topic] dead_letter_topic The {Topic} to which dead letter messages for the subscription should be
         | 
| 289 293 | 
             
                    #   published. Dead lettering is done on a best effort basis. The same message might be dead lettered multiple
         | 
| 290 294 | 
             
                    #   times. The Cloud Pub/Sub service account associated with the enclosing subscription's parent project (i.e.,
         | 
| @@ -297,6 +301,13 @@ module Google | |
| 297 301 | 
             
                    #   the subscription's dead letter policy. Dead lettering is done on a best effort basis. The same message might
         | 
| 298 302 | 
             
                    #   be dead lettered multiple times. The value must be between 5 and 100. If this parameter is 0, a default
         | 
| 299 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.
         | 
| 300 311 | 
             
                    #
         | 
| 301 312 | 
             
                    # @return [Google::Cloud::PubSub::Subscription]
         | 
| 302 313 | 
             
                    #
         | 
| @@ -340,17 +351,30 @@ module Google | |
| 340 351 | 
             
                    #                         dead_letter_topic: dead_letter_topic,
         | 
| 341 352 | 
             
                    #                         dead_letter_max_delivery_attempts: 10
         | 
| 342 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 | 
            +
                    #
         | 
| 343 364 | 
             
                    def subscribe subscription_name, deadline: nil, retain_acked: false, retention: nil, endpoint: nil, labels: nil,
         | 
| 344 | 
            -
                                  message_ordering: nil,  | 
| 365 | 
            +
                                  message_ordering: nil, filter: nil, dead_letter_topic: nil,
         | 
| 366 | 
            +
                                  dead_letter_max_delivery_attempts: nil, retry_policy: nil
         | 
| 345 367 | 
             
                      ensure_service!
         | 
| 346 368 | 
             
                      options = { deadline: deadline, retain_acked: retain_acked, retention: retention, endpoint: endpoint,
         | 
| 347 | 
            -
                                  labels: labels, message_ordering: message_ordering,
         | 
| 369 | 
            +
                                  labels: labels, message_ordering: message_ordering, filter: filter,
         | 
| 348 370 | 
             
                                  dead_letter_max_delivery_attempts: dead_letter_max_delivery_attempts }
         | 
| 371 | 
            +
             | 
| 349 372 | 
             
                      options[:dead_letter_topic_name] = dead_letter_topic.name if dead_letter_topic
         | 
| 350 373 | 
             
                      if options[:dead_letter_max_delivery_attempts] && !options[:dead_letter_topic_name]
         | 
| 351 374 | 
             
                        # Service error message "3:Invalid resource name given (name=)." does not identify param.
         | 
| 352 375 | 
             
                        raise ArgumentError, "dead_letter_topic is required with dead_letter_max_delivery_attempts"
         | 
| 353 376 | 
             
                      end
         | 
| 377 | 
            +
                      options[:retry_policy] = retry_policy.to_grpc if retry_policy
         | 
| 354 378 | 
             
                      grpc = service.create_subscription name, subscription_name, options
         | 
| 355 379 | 
             
                      Subscription.from_grpc grpc, service
         | 
| 356 380 | 
             
                    end
         | 
| @@ -17,6 +17,7 @@ module Google | |
| 17 17 | 
             
              module Cloud
         | 
| 18 18 | 
             
              module PubSub
         | 
| 19 19 | 
             
                module V1
         | 
| 20 | 
            +
                  # A policy constraining the storage of messages published to the topic.
         | 
| 20 21 | 
             
                  # @!attribute [rw] allowed_persistence_regions
         | 
| 21 22 | 
             
                  #   @return [Array<String>]
         | 
| 22 23 | 
             
                  #     A list of IDs of GCP regions where messages that are published to the topic
         | 
| @@ -67,7 +68,8 @@ module Google | |
| 67 68 | 
             
                  # @!attribute [rw] attributes
         | 
| 68 69 | 
             
                  #   @return [Hash{String => String}]
         | 
| 69 70 | 
             
                  #     Attributes for this message. If this field is empty, the message must
         | 
| 70 | 
            -
                  #     contain non-empty data.
         | 
| 71 | 
            +
                  #     contain non-empty data. This can be used to filter messages on the
         | 
| 72 | 
            +
                  #     subscription.
         | 
| 71 73 | 
             
                  # @!attribute [rw] message_id
         | 
| 72 74 | 
             
                  #   @return [String]
         | 
| 73 75 | 
             
                  #     ID of this message, assigned by the server when the message is published.
         | 
| @@ -173,7 +175,7 @@ module Google | |
| 173 175 | 
             
                  # Response for the `ListTopicSubscriptions` method.
         | 
| 174 176 | 
             
                  # @!attribute [rw] subscriptions
         | 
| 175 177 | 
             
                  #   @return [Array<String>]
         | 
| 176 | 
            -
                  #     The names of the  | 
| 178 | 
            +
                  #     The names of subscriptions attached to the topic specified in the request.
         | 
| 177 179 | 
             
                  # @!attribute [rw] next_page_token
         | 
| 178 180 | 
             
                  #   @return [String]
         | 
| 179 181 | 
             
                  #     If not empty, indicates that there may be more subscriptions that match
         | 
| @@ -214,6 +216,17 @@ module Google | |
| 214 216 | 
             
                  #     Format is `projects/{project}/topics/{topic}`.
         | 
| 215 217 | 
             
                  class DeleteTopicRequest; end
         | 
| 216 218 |  | 
| 219 | 
            +
                  # Request for the DetachSubscription method.
         | 
| 220 | 
            +
                  # @!attribute [rw] subscription
         | 
| 221 | 
            +
                  #   @return [String]
         | 
| 222 | 
            +
                  #     Required. The subscription to detach.
         | 
| 223 | 
            +
                  #     Format is `projects/{project}/subscriptions/{subscription}`.
         | 
| 224 | 
            +
                  class DetachSubscriptionRequest; end
         | 
| 225 | 
            +
             | 
| 226 | 
            +
                  # Response for the DetachSubscription method.
         | 
| 227 | 
            +
                  # Reserved for future use.
         | 
| 228 | 
            +
                  class DetachSubscriptionResponse; end
         | 
| 229 | 
            +
             | 
| 217 230 | 
             
                  # A subscription resource.
         | 
| 218 231 | 
             
                  # @!attribute [rw] name
         | 
| 219 232 | 
             
                  #   @return [String]
         | 
| @@ -295,13 +308,11 @@ module Google | |
| 295 308 | 
             
                  #     value for `expiration_policy.ttl` is 1 day.
         | 
| 296 309 | 
             
                  # @!attribute [rw] filter
         | 
| 297 310 | 
             
                  #   @return [String]
         | 
| 298 | 
            -
                  #     An expression written in the  | 
| 311 | 
            +
                  #     An expression written in the Pub/Sub [filter
         | 
| 312 | 
            +
                  #     language](https://cloud.google.com/pubsub/docs/filtering). If non-empty,
         | 
| 299 313 | 
             
                  #     then only `PubsubMessage`s whose `attributes` field matches the filter are
         | 
| 300 314 | 
             
                  #     delivered on this subscription. If empty, then no messages are filtered
         | 
| 301 315 | 
             
                  #     out.
         | 
| 302 | 
            -
                  #     <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
         | 
| 303 | 
            -
                  #     API might be changed in backward-incompatible ways and is not recommended
         | 
| 304 | 
            -
                  #     for production use. It is not subject to any SLA or deprecation policy.
         | 
| 305 316 | 
             
                  # @!attribute [rw] dead_letter_policy
         | 
| 306 317 | 
             
                  #   @return [Google::Cloud::PubSub::V1::DeadLetterPolicy]
         | 
| 307 318 | 
             
                  #     A policy that specifies the conditions for dead lettering messages in
         | 
| @@ -314,16 +325,20 @@ module Google | |
| 314 325 | 
             
                  #     permission to Acknowledge() messages on this subscription.
         | 
| 315 326 | 
             
                  # @!attribute [rw] retry_policy
         | 
| 316 327 | 
             
                  #   @return [Google::Cloud::PubSub::V1::RetryPolicy]
         | 
| 317 | 
            -
                  #     A policy that specifies how  | 
| 328 | 
            +
                  #     A policy that specifies how Pub/Sub retries message delivery for this
         | 
| 318 329 | 
             
                  #     subscription.
         | 
| 319 330 | 
             
                  #
         | 
| 320 331 | 
             
                  #     If not set, the default retry policy is applied. This generally implies
         | 
| 321 332 | 
             
                  #     that messages will be retried as soon as possible for healthy subscribers.
         | 
| 322 333 | 
             
                  #     RetryPolicy will be triggered on NACKs or acknowledgement deadline
         | 
| 323 334 | 
             
                  #     exceeded events for a given message.
         | 
| 324 | 
            -
                  # | 
| 325 | 
            -
                  # | 
| 326 | 
            -
                  #      | 
| 335 | 
            +
                  # @!attribute [rw] detached
         | 
| 336 | 
            +
                  #   @return [true, false]
         | 
| 337 | 
            +
                  #     Indicates whether the subscription is detached from its topic. Detached
         | 
| 338 | 
            +
                  #     subscriptions don't receive messages from their topic and don't retain any
         | 
| 339 | 
            +
                  #     backlog. `Pull` and `StreamingPull` requests will return
         | 
| 340 | 
            +
                  #     FAILED_PRECONDITION. If the subscription is a push subscription, pushes to
         | 
| 341 | 
            +
                  #     the endpoint will not be made.
         | 
| 327 342 | 
             
                  class Subscription; end
         | 
| 328 343 |  | 
| 329 344 | 
             
                  # A policy that specifies how Cloud Pub/Sub retries message delivery.
         | 
| @@ -455,8 +470,11 @@ module Google | |
| 455 470 | 
             
                  #     The message.
         | 
| 456 471 | 
             
                  # @!attribute [rw] delivery_attempt
         | 
| 457 472 | 
             
                  #   @return [Integer]
         | 
| 458 | 
            -
                  #      | 
| 459 | 
            -
                  #      | 
| 473 | 
            +
                  #     The approximate number of times that Cloud Pub/Sub has attempted to deliver
         | 
| 474 | 
            +
                  #     the associated message to a subscriber.
         | 
| 475 | 
            +
                  #
         | 
| 476 | 
            +
                  #     More precisely, this is 1 + (number of NACKs) +
         | 
| 477 | 
            +
                  #     (number of ack_deadline exceeds) for this message.
         | 
| 460 478 | 
             
                  #
         | 
| 461 479 | 
             
                  #     A NACK is any call to ModifyAckDeadline with a 0 deadline. An ack_deadline
         | 
| 462 480 | 
             
                  #     exceeds event is whenever a message is not acknowledged within
         | 
| @@ -464,13 +482,10 @@ module Google | |
| 464 482 | 
             
                  #     Subscription.ackDeadlineSeconds, but may get extended automatically by
         | 
| 465 483 | 
             
                  #     the client library.
         | 
| 466 484 | 
             
                  #
         | 
| 467 | 
            -
                  #      | 
| 468 | 
            -
                  #     is calculated at best effort and is approximate.
         | 
| 485 | 
            +
                  #     Upon the first delivery of a given message, `delivery_attempt` will have a
         | 
| 486 | 
            +
                  #     value of 1. The value is calculated at best effort and is approximate.
         | 
| 469 487 | 
             
                  #
         | 
| 470 488 | 
             
                  #     If a DeadLetterPolicy is not set on the subscription, this will be 0.
         | 
| 471 | 
            -
                  #     <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
         | 
| 472 | 
            -
                  #     API might be changed in backward-incompatible ways and is not recommended
         | 
| 473 | 
            -
                  #     for production use. It is not subject to any SLA or deprecation policy.
         | 
| 474 489 | 
             
                  class ReceivedMessage; end
         | 
| 475 490 |  | 
| 476 491 | 
             
                  # Request for the GetSubscription method.
         | 
| @@ -650,6 +665,28 @@ module Google | |
| 650 665 | 
             
                  #     to the same value so that state associated with the old stream can be
         | 
| 651 666 | 
             
                  #     transferred to the new stream. The same client_id should not be used for
         | 
| 652 667 | 
             
                  #     different client instances.
         | 
| 668 | 
            +
                  # @!attribute [rw] max_outstanding_messages
         | 
| 669 | 
            +
                  #   @return [Integer]
         | 
| 670 | 
            +
                  #     Flow control settings for the maximum number of outstanding messages. When
         | 
| 671 | 
            +
                  #     there are `max_outstanding_messages` or more currently sent to the
         | 
| 672 | 
            +
                  #     streaming pull client that have not yet been acked or nacked, the server
         | 
| 673 | 
            +
                  #     stops sending more messages. The sending of messages resumes once the
         | 
| 674 | 
            +
                  #     number of outstanding messages is less than this value. If the value is
         | 
| 675 | 
            +
                  #     <= 0, there is no limit to the number of outstanding messages. This
         | 
| 676 | 
            +
                  #     property can only be set on the initial StreamingPullRequest. If it is set
         | 
| 677 | 
            +
                  #     on a subsequent request, the stream will be aborted with status
         | 
| 678 | 
            +
                  #     `INVALID_ARGUMENT`.
         | 
| 679 | 
            +
                  # @!attribute [rw] max_outstanding_bytes
         | 
| 680 | 
            +
                  #   @return [Integer]
         | 
| 681 | 
            +
                  #     Flow control settings for the maximum number of outstanding bytes. When
         | 
| 682 | 
            +
                  #     there are `max_outstanding_bytes` or more worth of messages currently sent
         | 
| 683 | 
            +
                  #     to the streaming pull client that have not yet been acked or nacked, the
         | 
| 684 | 
            +
                  #     server will stop sending more messages. The sending of messages resumes
         | 
| 685 | 
            +
                  #     once the number of outstanding bytes is less than this value. If the value
         | 
| 686 | 
            +
                  #     is <= 0, there is no limit to the number of outstanding bytes. This
         | 
| 687 | 
            +
                  #     property can only be set on the initial StreamingPullRequest. If it is set
         | 
| 688 | 
            +
                  #     on a subsequent request, the stream will be aborted with status
         | 
| 689 | 
            +
                  #     `INVALID_ARGUMENT`.
         | 
| 653 690 | 
             
                  class StreamingPullRequest; end
         | 
| 654 691 |  | 
| 655 692 | 
             
                  # Response for the `StreamingPull` method. This response is used to stream
         | 
| @@ -98,6 +98,12 @@ module Google | |
| 98 98 |  | 
| 99 99 | 
             
                      private_constant :PROJECT_PATH_TEMPLATE
         | 
| 100 100 |  | 
| 101 | 
            +
                      SUBSCRIPTION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
         | 
| 102 | 
            +
                        "projects/{project}/subscriptions/{subscription}"
         | 
| 103 | 
            +
                      )
         | 
| 104 | 
            +
             | 
| 105 | 
            +
                      private_constant :SUBSCRIPTION_PATH_TEMPLATE
         | 
| 106 | 
            +
             | 
| 101 107 | 
             
                      TOPIC_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
         | 
| 102 108 | 
             
                        "projects/{project}/topics/{topic}"
         | 
| 103 109 | 
             
                      )
         | 
| @@ -113,6 +119,17 @@ module Google | |
| 113 119 | 
             
                        )
         | 
| 114 120 | 
             
                      end
         | 
| 115 121 |  | 
| 122 | 
            +
                      # Returns a fully-qualified subscription resource name string.
         | 
| 123 | 
            +
                      # @param project [String]
         | 
| 124 | 
            +
                      # @param subscription [String]
         | 
| 125 | 
            +
                      # @return [String]
         | 
| 126 | 
            +
                      def self.subscription_path project, subscription
         | 
| 127 | 
            +
                        SUBSCRIPTION_PATH_TEMPLATE.render(
         | 
| 128 | 
            +
                          :"project" => project,
         | 
| 129 | 
            +
                          :"subscription" => subscription
         | 
| 130 | 
            +
                        )
         | 
| 131 | 
            +
                      end
         | 
| 132 | 
            +
             | 
| 116 133 | 
             
                      # Returns a fully-qualified topic resource name string.
         | 
| 117 134 | 
             
                      # @param project [String]
         | 
| 118 135 | 
             
                      # @param topic [String]
         | 
| @@ -336,6 +353,14 @@ module Google | |
| 336 353 | 
             
                            {'resource' => request.resource}
         | 
| 337 354 | 
             
                          end
         | 
| 338 355 | 
             
                        )
         | 
| 356 | 
            +
                        @detach_subscription = Google::Gax.create_api_call(
         | 
| 357 | 
            +
                          @publisher_stub.method(:detach_subscription),
         | 
| 358 | 
            +
                          defaults["detach_subscription"],
         | 
| 359 | 
            +
                          exception_transformer: exception_transformer,
         | 
| 360 | 
            +
                          params_extractor: proc do |request|
         | 
| 361 | 
            +
                            {'subscription' => request.subscription}
         | 
| 362 | 
            +
                          end
         | 
| 363 | 
            +
                        )
         | 
| 339 364 | 
             
                      end
         | 
| 340 365 |  | 
| 341 366 | 
             
                      # Service calls
         | 
| @@ -572,7 +597,7 @@ module Google | |
| 572 597 | 
             
                        @list_topics.call(req, options, &block)
         | 
| 573 598 | 
             
                      end
         | 
| 574 599 |  | 
| 575 | 
            -
                      # Lists the names of the subscriptions on this topic.
         | 
| 600 | 
            +
                      # Lists the names of the attached subscriptions on this topic.
         | 
| 576 601 | 
             
                      #
         | 
| 577 602 | 
             
                      # @param topic [String]
         | 
| 578 603 | 
             
                      #   Required. The name of the topic that subscriptions are attached to.
         | 
| @@ -860,6 +885,40 @@ module Google | |
| 860 885 | 
             
                        req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
         | 
| 861 886 | 
             
                        @test_iam_permissions.call(req, options, &block)
         | 
| 862 887 | 
             
                      end
         | 
| 888 | 
            +
             | 
| 889 | 
            +
                      # Detaches a subscription from this topic. All messages retained in the
         | 
| 890 | 
            +
                      # subscription are dropped. Subsequent `Pull` and `StreamingPull` requests
         | 
| 891 | 
            +
                      # will return FAILED_PRECONDITION. If the subscription is a push
         | 
| 892 | 
            +
                      # subscription, pushes to the endpoint will stop.
         | 
| 893 | 
            +
                      #
         | 
| 894 | 
            +
                      # @param subscription [String]
         | 
| 895 | 
            +
                      #   Required. The subscription to detach.
         | 
| 896 | 
            +
                      #   Format is `projects/{project}/subscriptions/{subscription}`.
         | 
| 897 | 
            +
                      # @param options [Google::Gax::CallOptions]
         | 
| 898 | 
            +
                      #   Overrides the default settings for this call, e.g, timeout,
         | 
| 899 | 
            +
                      #   retries, etc.
         | 
| 900 | 
            +
                      # @yield [result, operation] Access the result along with the RPC operation
         | 
| 901 | 
            +
                      # @yieldparam result [Google::Cloud::PubSub::V1::DetachSubscriptionResponse]
         | 
| 902 | 
            +
                      # @yieldparam operation [GRPC::ActiveCall::Operation]
         | 
| 903 | 
            +
                      # @return [Google::Cloud::PubSub::V1::DetachSubscriptionResponse]
         | 
| 904 | 
            +
                      # @raise [Google::Gax::GaxError] if the RPC is aborted.
         | 
| 905 | 
            +
                      # @example
         | 
| 906 | 
            +
                      #   require "google/cloud/pubsub"
         | 
| 907 | 
            +
                      #
         | 
| 908 | 
            +
                      #   publisher_client = Google::Cloud::PubSub::Publisher.new(version: :v1)
         | 
| 909 | 
            +
                      #   formatted_subscription = Google::Cloud::PubSub::V1::PublisherClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
         | 
| 910 | 
            +
                      #   response = publisher_client.detach_subscription(formatted_subscription)
         | 
| 911 | 
            +
             | 
| 912 | 
            +
                      def detach_subscription \
         | 
| 913 | 
            +
                          subscription,
         | 
| 914 | 
            +
                          options: nil,
         | 
| 915 | 
            +
                          &block
         | 
| 916 | 
            +
                        req = {
         | 
| 917 | 
            +
                          subscription: subscription
         | 
| 918 | 
            +
                        }.delete_if { |_, v| v.nil? }
         | 
| 919 | 
            +
                        req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::DetachSubscriptionRequest)
         | 
| 920 | 
            +
                        @detach_subscription.call(req, options, &block)
         | 
| 921 | 
            +
                      end
         | 
| 863 922 | 
             
                    end
         | 
| 864 923 | 
             
                  end
         | 
| 865 924 | 
             
                end
         | 
| @@ -7,6 +7,7 @@ | |
| 7 7 | 
             
                      "UNAVAILABLE",
         | 
| 8 8 | 
             
                      "UNKNOWN"
         | 
| 9 9 | 
             
                    ],
         | 
| 10 | 
            +
                    "non_idempotent2": [],
         | 
| 10 11 | 
             
                    "non_idempotent": [
         | 
| 11 12 | 
             
                      "UNAVAILABLE"
         | 
| 12 13 | 
             
                    ],
         | 
| @@ -107,6 +108,11 @@ | |
| 107 108 | 
             
                      "timeout_millis": 60000,
         | 
| 108 109 | 
             
                      "retry_codes_name": "non_idempotent",
         | 
| 109 110 | 
             
                      "retry_params_name": "default"
         | 
| 111 | 
            +
                    },
         | 
| 112 | 
            +
                    "DetachSubscription": {
         | 
| 113 | 
            +
                      "timeout_millis": 60000,
         | 
| 114 | 
            +
                      "retry_codes_name": "non_idempotent2",
         | 
| 115 | 
            +
                      "retry_params_name": "default"
         | 
| 110 116 | 
             
                    }
         | 
| 111 117 | 
             
                  }
         | 
| 112 118 | 
             
                }
         | 
| @@ -510,13 +510,11 @@ module Google | |
| 510 510 | 
             
                      #   A hash of the same form as `Google::Cloud::PubSub::V1::ExpirationPolicy`
         | 
| 511 511 | 
             
                      #   can also be provided.
         | 
| 512 512 | 
             
                      # @param filter [String]
         | 
| 513 | 
            -
                      #   An expression written in the  | 
| 513 | 
            +
                      #   An expression written in the Pub/Sub [filter
         | 
| 514 | 
            +
                      #   language](https://cloud.google.com/pubsub/docs/filtering). If non-empty,
         | 
| 514 515 | 
             
                      #   then only `PubsubMessage`s whose `attributes` field matches the filter are
         | 
| 515 516 | 
             
                      #   delivered on this subscription. If empty, then no messages are filtered
         | 
| 516 517 | 
             
                      #   out.
         | 
| 517 | 
            -
                      #   <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
         | 
| 518 | 
            -
                      #   API might be changed in backward-incompatible ways and is not recommended
         | 
| 519 | 
            -
                      #   for production use. It is not subject to any SLA or deprecation policy.
         | 
| 520 518 | 
             
                      # @param dead_letter_policy [Google::Cloud::PubSub::V1::DeadLetterPolicy | Hash]
         | 
| 521 519 | 
             
                      #   A policy that specifies the conditions for dead lettering messages in
         | 
| 522 520 | 
             
                      #   this subscription. If dead_letter_policy is not set, dead lettering
         | 
| @@ -529,18 +527,21 @@ module Google | |
| 529 527 | 
             
                      #   A hash of the same form as `Google::Cloud::PubSub::V1::DeadLetterPolicy`
         | 
| 530 528 | 
             
                      #   can also be provided.
         | 
| 531 529 | 
             
                      # @param retry_policy [Google::Cloud::PubSub::V1::RetryPolicy | Hash]
         | 
| 532 | 
            -
                      #   A policy that specifies how  | 
| 530 | 
            +
                      #   A policy that specifies how Pub/Sub retries message delivery for this
         | 
| 533 531 | 
             
                      #   subscription.
         | 
| 534 532 | 
             
                      #
         | 
| 535 533 | 
             
                      #   If not set, the default retry policy is applied. This generally implies
         | 
| 536 534 | 
             
                      #   that messages will be retried as soon as possible for healthy subscribers.
         | 
| 537 535 | 
             
                      #   RetryPolicy will be triggered on NACKs or acknowledgement deadline
         | 
| 538 536 | 
             
                      #   exceeded events for a given message.
         | 
| 539 | 
            -
                      #   <b>EXPERIMENTAL:</b> This API might be changed in backward-incompatible
         | 
| 540 | 
            -
                      #   ways and is not recommended for production use. It is not subject to any
         | 
| 541 | 
            -
                      #   SLA or deprecation policy.
         | 
| 542 537 | 
             
                      #   A hash of the same form as `Google::Cloud::PubSub::V1::RetryPolicy`
         | 
| 543 538 | 
             
                      #   can also be provided.
         | 
| 539 | 
            +
                      # @param detached [true, false]
         | 
| 540 | 
            +
                      #   Indicates whether the subscription is detached from its topic. Detached
         | 
| 541 | 
            +
                      #   subscriptions don't receive messages from their topic and don't retain any
         | 
| 542 | 
            +
                      #   backlog. `Pull` and `StreamingPull` requests will return
         | 
| 543 | 
            +
                      #   FAILED_PRECONDITION. If the subscription is a push subscription, pushes to
         | 
| 544 | 
            +
                      #   the endpoint will not be made.
         | 
| 544 545 | 
             
                      # @param options [Google::Gax::CallOptions]
         | 
| 545 546 | 
             
                      #   Overrides the default settings for this call, e.g, timeout,
         | 
| 546 547 | 
             
                      #   retries, etc.
         | 
| @@ -570,6 +571,7 @@ module Google | |
| 570 571 | 
             
                          filter: nil,
         | 
| 571 572 | 
             
                          dead_letter_policy: nil,
         | 
| 572 573 | 
             
                          retry_policy: nil,
         | 
| 574 | 
            +
                          detached: nil,
         | 
| 573 575 | 
             
                          options: nil,
         | 
| 574 576 | 
             
                          &block
         | 
| 575 577 | 
             
                        req = {
         | 
| @@ -584,7 +586,8 @@ module Google | |
| 584 586 | 
             
                          expiration_policy: expiration_policy,
         | 
| 585 587 | 
             
                          filter: filter,
         | 
| 586 588 | 
             
                          dead_letter_policy: dead_letter_policy,
         | 
| 587 | 
            -
                          retry_policy: retry_policy
         | 
| 589 | 
            +
                          retry_policy: retry_policy,
         | 
| 590 | 
            +
                          detached: detached
         | 
| 588 591 | 
             
                        }.delete_if { |_, v| v.nil? }
         | 
| 589 592 | 
             
                        req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::Subscription)
         | 
| 590 593 | 
             
                        @create_subscription.call(req, options, &block)
         | 
| @@ -73,6 +73,11 @@ Google::Protobuf::DescriptorPool.generated_pool.build do | |
| 73 73 | 
             
              add_message "google.pubsub.v1.DeleteTopicRequest" do
         | 
| 74 74 | 
             
                optional :topic, :string, 1
         | 
| 75 75 | 
             
              end
         | 
| 76 | 
            +
              add_message "google.pubsub.v1.DetachSubscriptionRequest" do
         | 
| 77 | 
            +
                optional :subscription, :string, 1
         | 
| 78 | 
            +
              end
         | 
| 79 | 
            +
              add_message "google.pubsub.v1.DetachSubscriptionResponse" do
         | 
| 80 | 
            +
              end
         | 
| 76 81 | 
             
              add_message "google.pubsub.v1.Subscription" do
         | 
| 77 82 | 
             
                optional :name, :string, 1
         | 
| 78 83 | 
             
                optional :topic, :string, 2
         | 
| @@ -86,6 +91,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do | |
| 86 91 | 
             
                optional :filter, :string, 12
         | 
| 87 92 | 
             
                optional :dead_letter_policy, :message, 13, "google.pubsub.v1.DeadLetterPolicy"
         | 
| 88 93 | 
             
                optional :retry_policy, :message, 14, "google.pubsub.v1.RetryPolicy"
         | 
| 94 | 
            +
                optional :detached, :bool, 15
         | 
| 89 95 | 
             
              end
         | 
| 90 96 | 
             
              add_message "google.pubsub.v1.RetryPolicy" do
         | 
| 91 97 | 
             
                optional :minimum_backoff, :message, 1, "google.protobuf.Duration"
         | 
| @@ -161,6 +167,8 @@ Google::Protobuf::DescriptorPool.generated_pool.build do | |
| 161 167 | 
             
                repeated :modify_deadline_ack_ids, :string, 4
         | 
| 162 168 | 
             
                optional :stream_ack_deadline_seconds, :int32, 5
         | 
| 163 169 | 
             
                optional :client_id, :string, 6
         | 
| 170 | 
            +
                optional :max_outstanding_messages, :int64, 7
         | 
| 171 | 
            +
                optional :max_outstanding_bytes, :int64, 8
         | 
| 164 172 | 
             
              end
         | 
| 165 173 | 
             
              add_message "google.pubsub.v1.StreamingPullResponse" do
         | 
| 166 174 | 
             
                repeated :received_messages, :message, 1, "google.pubsub.v1.ReceivedMessage"
         | 
| @@ -228,6 +236,8 @@ module Google::Cloud::PubSub::V1 | |
| 228 236 | 
             
              ListTopicSnapshotsRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.ListTopicSnapshotsRequest").msgclass
         | 
| 229 237 | 
             
              ListTopicSnapshotsResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.ListTopicSnapshotsResponse").msgclass
         | 
| 230 238 | 
             
              DeleteTopicRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.DeleteTopicRequest").msgclass
         | 
| 239 | 
            +
              DetachSubscriptionRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.DetachSubscriptionRequest").msgclass
         | 
| 240 | 
            +
              DetachSubscriptionResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.DetachSubscriptionResponse").msgclass
         | 
| 231 241 | 
             
              Subscription = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.Subscription").msgclass
         | 
| 232 242 | 
             
              RetryPolicy = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.RetryPolicy").msgclass
         | 
| 233 243 | 
             
              DeadLetterPolicy = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.DeadLetterPolicy").msgclass
         | 
| @@ -53,7 +53,7 @@ module Google::Cloud::PubSub::V1 | |
| 53 53 | 
             
                  rpc :GetTopic, GetTopicRequest, Topic
         | 
| 54 54 | 
             
                  # Lists matching topics.
         | 
| 55 55 | 
             
                  rpc :ListTopics, ListTopicsRequest, ListTopicsResponse
         | 
| 56 | 
            -
                  # Lists the names of the subscriptions on this topic.
         | 
| 56 | 
            +
                  # Lists the names of the attached subscriptions on this topic.
         | 
| 57 57 | 
             
                  rpc :ListTopicSubscriptions, ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse
         | 
| 58 58 | 
             
                  # Lists the names of the snapshots on this topic. Snapshots are used in
         | 
| 59 59 | 
             
                  # <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
         | 
| @@ -68,6 +68,11 @@ module Google::Cloud::PubSub::V1 | |
| 68 68 | 
             
                  # configuration or subscriptions. Existing subscriptions to this topic are
         | 
| 69 69 | 
             
                  # not deleted, but their `topic` field is set to `_deleted-topic_`.
         | 
| 70 70 | 
             
                  rpc :DeleteTopic, DeleteTopicRequest, Google::Protobuf::Empty
         | 
| 71 | 
            +
                  # Detaches a subscription from this topic. All messages retained in the
         | 
| 72 | 
            +
                  # subscription are dropped. Subsequent `Pull` and `StreamingPull` requests
         | 
| 73 | 
            +
                  # will return FAILED_PRECONDITION. If the subscription is a push
         | 
| 74 | 
            +
                  # subscription, pushes to the endpoint will stop.
         | 
| 75 | 
            +
                  rpc :DetachSubscription, DetachSubscriptionRequest, DetachSubscriptionResponse
         | 
| 71 76 | 
             
                end
         | 
| 72 77 |  | 
| 73 78 | 
             
                Stub = Service.rpc_stub_class
         | 
    
        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. | 
| 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- | 
| 12 | 
            +
            date: 2020-07-23 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: concurrent-ruby
         | 
| @@ -278,6 +278,7 @@ files: | |
| 278 278 | 
             
            - lib/google/cloud/pubsub/project.rb
         | 
| 279 279 | 
             
            - lib/google/cloud/pubsub/publish_result.rb
         | 
| 280 280 | 
             
            - lib/google/cloud/pubsub/received_message.rb
         | 
| 281 | 
            +
            - lib/google/cloud/pubsub/retry_policy.rb
         | 
| 281 282 | 
             
            - lib/google/cloud/pubsub/service.rb
         | 
| 282 283 | 
             
            - lib/google/cloud/pubsub/snapshot.rb
         | 
| 283 284 | 
             
            - lib/google/cloud/pubsub/snapshot/list.rb
         | 
| @@ -329,7 +330,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 329 330 | 
             
                - !ruby/object:Gem::Version
         | 
| 330 331 | 
             
                  version: '0'
         | 
| 331 332 | 
             
            requirements: []
         | 
| 332 | 
            -
            rubygems_version: 3. | 
| 333 | 
            +
            rubygems_version: 3.1.3
         | 
| 333 334 | 
             
            signing_key: 
         | 
| 334 335 | 
             
            specification_version: 4
         | 
| 335 336 | 
             
            summary: API Client library for Google Cloud Pub/Sub
         |