Class: Fog::Rackspace::Queues::Claim
- Defined in:
- lib/fog/rackspace/models/queues/claim.rb
Instance Attribute Summary collapse
-
#grace ⇒ Integer
The grace attribute specifies the message grace period in seconds.
-
#identity ⇒ String
(also: #id)
readonly
The claim’s id.
-
#limit ⇒ Array<Fog::Rackspace::Queues::Messages>, Array<Strings>
Specifies the number of messages to return, up to 20 messages.
-
#ttl ⇒ Integer
The ttl attribute specifies how long the server waits before releasing the claim.
Attributes inherited from Model
Instance Method Summary collapse
-
#destroy ⇒ Boolean
Destroys Claim.
-
#initialize(new_attributes = {}) ⇒ Claim
constructor
A new instance of Claim.
- #messages=(messages) ⇒ Object
-
#save ⇒ Boolean
Creates or updates a claim.
Methods inherited from Model
#inspect, #reload, #symbolize_keys, #to_json, #wait_for
Methods included from Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #ignore_attributes, #ignored_attributes
Methods included from Core::DeprecatedConnectionAccessors
#connection, #connection=, #prepare_service_value
Methods included from Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one
Constructor Details
#initialize(new_attributes = {}) ⇒ Claim
Returns a new instance of Claim.
97 98 99 100 101 102 103 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 97 def initialize(new_attributes = {}) # A hack in support of the #messages= hack up above. #messages= requires #collection to # be populated first to succeed, which is always the case in modern Rubies that preserve # Hash ordering, but not in 1.8.7. @collection = new_attributes.delete(:collection) super(new_attributes) end |
Instance Attribute Details
#grace ⇒ Integer
Returns The grace attribute specifies the message grace period in seconds. The value of grace value must be between 60 and 43200 seconds (12 hours). You must include a value for this attribute in your request. To deal with workers that have stopped responding (for up to 1209600 seconds or 14 days, including claim lifetime), the server extends the lifetime of claimed messages to be at least as long as the lifetime of the claim itself, plus the specified grace period. If a claimed message would normally live longer than the grace period, its expiration is not adjusted.
17 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 17 attribute :grace |
#identity ⇒ String (readonly) Also known as: id
Returns The claim’s id.
10 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 10 identity :identity |
#limit ⇒ Array<Fog::Rackspace::Queues::Messages>, Array<Strings>
Returns Specifies the number of messages to return, up to 20 messages. If limit is not specified, limit defaults to 10.
25 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 25 attribute :limit |
#ttl ⇒ Integer
Returns The ttl attribute specifies how long the server waits before releasing the claim. The ttl value must be between 60 and 43200 seconds (12 hours).
21 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 21 attribute :ttl |
Instance Method Details
#destroy ⇒ Boolean
Destroys Claim
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 61 def destroy requires :identity, :queue service.delete_claim(queue.name, identity) #Since Claims aren't a server side collection, we should remove # the claim from the collection. collection.delete(self) true end |
#messages=(messages) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 72 def () #HACK - Models require a collection, but I don't really want to expose # the messages collection to users here. = Fog::Rackspace::Queues::Messages.new({ :service => service, :queue => queue, :client_id => service.client_id, :echo => true }) attributes[:messages] = .collect do || if .instance_of? Fog::Rackspace::Queues::Message .claim_id = self.id else Fog::Rackspace::Queues::Message.new( .merge({ :service => service, :collection => , :claim_id => self.id }.merge()) ) end end end |
#save ⇒ Boolean
Creates or updates a claim
44 45 46 47 48 49 50 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 44 def save if identity.nil? create else update end end |