Class: Fog::Rackspace::Queues::Mock::MockClaim
- Inherits:
-
Object
- Object
- Fog::Rackspace::Queues::Mock::MockClaim
- Defined in:
- lib/fog/rackspace/queues.rb
Overview
Reservation indicating that a consumer is in the process of handling a collection of messages from a queue.
Instance Attribute Summary collapse
-
#grace ⇒ Object
Returns the value of attribute grace.
-
#id ⇒ Object
Returns the value of attribute id.
-
#queue ⇒ Object
Returns the value of attribute queue.
-
#ttl ⇒ Object
Returns the value of attribute ttl.
Instance Method Summary collapse
-
#age ⇒ Integer
Determine how long ago this claim was created, in seconds.
-
#expired? ⇒ Boolean
Determine if this claim has lasted longer than its designated ttl.
-
#initialize(queue, ttl, grace) ⇒ MockClaim
constructor
Create a new MockClaim.
-
#message_end_of_life ⇒ Integer
Calculate the time at which messages belonging to this claim should expire.
-
#messages ⇒ Array<Message>
Access the collection of messages owned by this claim.
-
#to_h ⇒ Hash
Convert this claim into a GET payload.
-
#touch! ⇒ Object
Set or reset the creation time of the claim to the present.
Constructor Details
#initialize(queue, ttl, grace) ⇒ MockClaim
Create a new MockClaim. Clients should use Fog::Rackspace::Queues::Mock::MockQueue#add_claim instead.
260 261 262 263 264 265 |
# File 'lib/fog/rackspace/queues.rb', line 260 def initialize(queue, ttl, grace) @queue = queue @id = Fog::Mock.random_hex(24) @ttl, @grace = ttl, grace touch! end |
Instance Attribute Details
#grace ⇒ Object
Returns the value of attribute grace.
252 253 254 |
# File 'lib/fog/rackspace/queues.rb', line 252 def grace @grace end |
#id ⇒ Object
Returns the value of attribute id.
252 253 254 |
# File 'lib/fog/rackspace/queues.rb', line 252 def id @id end |
#queue ⇒ Object
Returns the value of attribute queue.
252 253 254 |
# File 'lib/fog/rackspace/queues.rb', line 252 def queue @queue end |
#ttl ⇒ Object
Returns the value of attribute ttl.
252 253 254 |
# File 'lib/fog/rackspace/queues.rb', line 252 def ttl @ttl end |
Instance Method Details
#age ⇒ Integer
Determine how long ago this claim was created, in seconds.
282 283 284 |
# File 'lib/fog/rackspace/queues.rb', line 282 def age Time.now.to_i - @created end |
#expired? ⇒ Boolean
Determine if this claim has lasted longer than its designated ttl.
289 290 291 |
# File 'lib/fog/rackspace/queues.rb', line 289 def expired? age > ttl end |
#message_end_of_life ⇒ Integer
Calculate the time at which messages belonging to this claim should expire.
275 276 277 |
# File 'lib/fog/rackspace/queues.rb', line 275 def @created + @ttl + @grace end |
#messages ⇒ Array<Message>
Access the collection of messages owned by this claim.
296 297 298 |
# File 'lib/fog/rackspace/queues.rb', line 296 def @queue..select { |m| m.claim == self } end |