Class: TQ::Task
- Inherits:
-
Struct
- Object
- Struct
- TQ::Task
- Defined in:
- lib/tq/queue.rb
Instance Attribute Summary collapse
-
#expires ⇒ Object
Returns the value of attribute expires.
-
#id ⇒ Object
Returns the value of attribute id.
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#queue ⇒ Object
Returns the value of attribute queue.
-
#raw ⇒ Object
Returns the value of attribute raw.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#tries ⇒ Object
Returns the value of attribute tries.
Instance Method Summary collapse
- #clock!(_) ⇒ Object
- #extend!(secs = nil) ⇒ Object
- #finish! ⇒ Object
-
#initialize(*args) ⇒ Task
constructor
A new instance of Task.
- #lease_expired? ⇒ Boolean
- #lease_remaining ⇒ Object
- #reset_clock! ⇒ Object
- #try? ⇒ Boolean
Constructor Details
#initialize(*args) ⇒ Task
Returns a new instance of Task.
124 125 126 127 |
# File 'lib/tq/queue.rb', line 124 def initialize(*args) super @clock = Time end |
Instance Attribute Details
#expires ⇒ Object
Returns the value of attribute expires
122 123 124 |
# File 'lib/tq/queue.rb', line 122 def expires @expires end |
#id ⇒ Object
Returns the value of attribute id
122 123 124 |
# File 'lib/tq/queue.rb', line 122 def id @id end |
#payload ⇒ Object
Returns the value of attribute payload
122 123 124 |
# File 'lib/tq/queue.rb', line 122 def payload @payload end |
#queue ⇒ Object
Returns the value of attribute queue
122 123 124 |
# File 'lib/tq/queue.rb', line 122 def queue @queue end |
#raw ⇒ Object
Returns the value of attribute raw
122 123 124 |
# File 'lib/tq/queue.rb', line 122 def raw @raw end |
#tag ⇒ Object
Returns the value of attribute tag
122 123 124 |
# File 'lib/tq/queue.rb', line 122 def tag @tag end |
#tries ⇒ Object
Returns the value of attribute tries
122 123 124 |
# File 'lib/tq/queue.rb', line 122 def tries @tries end |
Instance Method Details
#clock!(_) ⇒ Object
137 138 139 |
# File 'lib/tq/queue.rb', line 137 def clock!(_) @clock = _; return self end |
#extend!(secs = nil) ⇒ Object
133 134 135 |
# File 'lib/tq/queue.rb', line 133 def extend!(secs=nil) self.queue.extend!(self, secs) end |
#finish! ⇒ Object
129 130 131 |
# File 'lib/tq/queue.rb', line 129 def finish! self.queue.finish!(self) end |
#lease_expired? ⇒ Boolean
149 150 151 |
# File 'lib/tq/queue.rb', line 149 def lease_expired? self.expires < @clock.now end |
#lease_remaining ⇒ Object
145 146 147 |
# File 'lib/tq/queue.rb', line 145 def lease_remaining self.expires - @clock.now end |
#reset_clock! ⇒ Object
141 142 143 |
# File 'lib/tq/queue.rb', line 141 def reset_clock! @clock = Time; return self end |
#try? ⇒ Boolean
153 154 155 156 |
# File 'lib/tq/queue.rb', line 153 def try? max = self.queue.option('max_tries') return (max == -1 or self.tries < max) end |