Class: Fog::Rackspace::Queues::Claim
- Inherits:
-
Model
- Object
- Model
- 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.
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.
Constructor Details
#initialize(new_attributes = {}) ⇒ Claim
Returns a new instance of Claim.
96 97 98 99 100 101 102 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 96 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.
16 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 16 attribute :grace |
#identity ⇒ String (readonly) Also known as: id
Returns The claim’s id.
9 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 9 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.
24 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 24 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).
20 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 20 attribute :ttl |
Instance Method Details
#destroy ⇒ Boolean
Destroys Claim
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 60 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
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 71 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] = .map 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
43 44 45 46 47 48 49 |
# File 'lib/fog/rackspace/models/queues/claim.rb', line 43 def save if identity.nil? create else update end end |