Class: Fog::Rackspace::Queues::Claim

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/rackspace/models/queues/claim.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#graceInteger

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.

Returns:

  • (Integer)

    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

#identityString (readonly) Also known as: id

Returns The claim’s id.

Returns:

  • (String)

    The claim’s id



9
# File 'lib/fog/rackspace/models/queues/claim.rb', line 9

identity :identity

#limitArray<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.

Returns:

  • (Array<Fog::Rackspace::Queues::Messages>, Array<Strings>)

    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

#ttlInteger

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).

Returns:

  • (Integer)

    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

#destroyBoolean

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 messages=(messages)
  #HACK - Models require a collection, but I don't really want to expose
  # the messages collection to users here.
  message_collection = Fog::Rackspace::Queues::Messages.new({
      :service => service,
      :queue => queue,
      :client_id => service.client_id,
      :echo => true
    })
  attributes[:messages] = messages.map do |message|
    if message.instance_of? Fog::Rackspace::Queues::Message
      message.claim_id = self.id
      message
    else
      Fog::Rackspace::Queues::Message.new(
        message.merge({
          :service => service,
          :collection => message_collection,
          :claim_id => self.id
        }.merge(message))
      )
    end
  end
end

#saveBoolean

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