Sha256: 4bdb37358cf78268355cedaa5747edb013f48279553a5300bbc26e2b869f4da4

Contents?: true

Size: 1.2 KB

Versions: 54

Compression:

Stored size: 1.2 KB

Contents

require "fog/core/model"

module Fog
  module Google
    class Pubsub
      # Represents a ReceivedMessage retrieved from a Google Pubsub
      # subscription. Note that ReceivedMessages are immutable.
      #
      # @see https://cloud.google.com/pubsub/reference/rest/v1/projects.subscriptions/pull#ReceivedMessage
      class ReceivedMessage < Fog::Model
        identity :ack_id, :aliases => "ackId"

        attribute :message

        def initialize(new_attributes = {})
          # Here we secretly store the subscription name we were received on
          # in order to support #acknowledge
          attributes = new_attributes.clone
          @subscription_name = attributes.delete(:subscription_name)
          super(attributes)
        end

        # Acknowledges a message.
        #
        # @see https://cloud.google.com/pubsub/reference/rest/v1/projects.subscriptions/acknowledge
        def acknowledge
          requires :ack_id

          service.acknowledge_subscription(@subscription_name, [ack_id])
          nil
        end

        def reload
          # Message is immutable - do nothing
          Fog::Logger.warning("#reload called on immutable ReceivedMessage")
        end
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 2 rubygems

Version Path
fog-google-1.24.1 lib/fog/google/models/pubsub/received_message.rb
fog-google-1.24.0 lib/fog/google/models/pubsub/received_message.rb
fog-google-1.23.0 lib/fog/google/models/pubsub/received_message.rb
fog-google-1.22.0 lib/fog/google/models/pubsub/received_message.rb
fog-google-1.21.1 lib/fog/google/models/pubsub/received_message.rb
fog-google-1.21.0 lib/fog/google/models/pubsub/received_message.rb
fog-google-1.20.0 lib/fog/google/models/pubsub/received_message.rb
fog-google-1.19.0 lib/fog/google/models/pubsub/received_message.rb
fog-google-1.18.0 lib/fog/google/models/pubsub/received_message.rb
fog-google-1.17.0 lib/fog/google/models/pubsub/received_message.rb
fog-google-1.16.1 lib/fog/google/models/pubsub/received_message.rb
fog-google-1.16.0 lib/fog/google/models/pubsub/received_message.rb
fog-google-1.15.0 lib/fog/google/models/pubsub/received_message.rb
fog-google-1.14.0 lib/fog/google/models/pubsub/received_message.rb
gitlab-fog-google-1.14.0 lib/fog/google/models/pubsub/received_message.rb
fog-google-1.13.0 lib/fog/google/models/pubsub/received_message.rb
gitlab-fog-google-1.13.0 lib/fog/google/models/pubsub/received_message.rb
fog-google-1.12.1 lib/fog/google/models/pubsub/received_message.rb
fog-google-1.12.0 lib/fog/google/models/pubsub/received_message.rb
fog-google-1.11.0 lib/fog/google/models/pubsub/received_message.rb