Class: Google::Cloud::PubSub::Snapshot
- Inherits:
-
Object
- Object
- Google::Cloud::PubSub::Snapshot
- Defined in:
- lib/google/cloud/pubsub/snapshot.rb,
lib/google/cloud/pubsub/snapshot/list.rb
Overview
Snapshot
A named resource created from a subscription to retain a stream of messages from a topic. A snapshot is guaranteed to retain:
- The existing backlog on the subscription. More precisely, this is
defined as the messages in the subscription's backlog that are
unacknowledged upon the successful completion of the
create_snapshot
operation; as well as: - Any messages published to the subscription's topic following the
successful completion of the
create_snapshot
operation.
Defined Under Namespace
Classes: List
Instance Method Summary collapse
-
#delete ⇒ Boolean
Removes an existing snapshot.
-
#expiration_time ⇒ Time
The snapshot is guaranteed to exist up until this time.
-
#labels ⇒ Hash
A hash of user-provided labels associated with this snapshot.
-
#labels=(new_labels) ⇒ Object
Sets the hash of user-provided labels associated with this snapshot.
-
#name ⇒ String
The name of the snapshot.
-
#topic ⇒ Topic
The Topic from which this snapshot is retaining messages.
Instance Method Details
#delete ⇒ Boolean
Removes an existing snapshot. All messages retained in the snapshot are immediately dropped. After a snapshot is deleted, a new one may be created with the same name, but the new one has no association with the old snapshot or its subscription, unless the same subscription is specified.
169 170 171 172 173 |
# File 'lib/google/cloud/pubsub/snapshot.rb', line 169 def delete ensure_service! service.delete_snapshot name true end |
#expiration_time ⇒ Time
The snapshot is guaranteed to exist up until this time. A newly-created snapshot expires no later than 7 days from the time of its creation. Its exact lifetime is determined at creation by the existing backlog in the source subscription. Specifically, the lifetime of the snapshot is 7 days - (age of oldest unacked message in the subscription). For example, consider a subscription whose oldest unacked message is 3 days old. If a snapshot is created from this subscription, the snapshot -- which will always capture this 3-day-old backlog as long as the snapshot exists -- will expire in 4 days.
112 113 114 |
# File 'lib/google/cloud/pubsub/snapshot.rb', line 112 def expiration_time self.class. @grpc.expire_time end |
#labels ⇒ Hash
A hash of user-provided labels associated with this snapshot. Labels can be used to organize and group snapshots.See Creating and Managing Labels.
The returned hash is frozen and changes are not allowed. Use #labels= to update the labels for this snapshot.
126 127 128 |
# File 'lib/google/cloud/pubsub/snapshot.rb', line 126 def labels @grpc.labels.to_h.freeze end |
#labels=(new_labels) ⇒ Object
Sets the hash of user-provided labels associated with this snapshot. Labels can be used to organize and group snapshots. Label keys and values can be no longer than 63 characters, can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter and each label in the list must have a different key. See Creating and Managing Labels.
142 143 144 145 146 147 148 149 |
# File 'lib/google/cloud/pubsub/snapshot.rb', line 142 def labels= new_labels raise ArgumentError, "Value must be a Hash" if new_labels.nil? labels_map = Google::Protobuf::Map.new :string, :string Hash(new_labels).each { |k, v| labels_map[String(k)] = String(v) } update_grpc = @grpc.dup update_grpc.labels = labels_map @grpc = service.update_snapshot update_grpc, :labels end |
#name ⇒ String
The name of the snapshot.
66 67 68 |
# File 'lib/google/cloud/pubsub/snapshot.rb', line 66 def name @grpc.name end |