Class: Sidekiq::Job
- Inherits:
-
Object
- Object
- Sidekiq::Job
- Defined in:
- lib/sidekiq/api.rb
Overview
Encapsulates a pending job within a Sidekiq queue or sorted set.
The job should be considered immutable but may be removed from the queue via Job#delete.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#item ⇒ Object
readonly
Returns the value of attribute item.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #args ⇒ Object
-
#delete ⇒ Object
Remove this job from the queue.
- #enqueued_at ⇒ Object
-
#initialize(item, queue_name = nil) ⇒ Job
constructor
A new instance of Job.
- #jid ⇒ Object
- #klass ⇒ Object
- #latency ⇒ Object
- #queue ⇒ Object
Constructor Details
Instance Attribute Details
#item ⇒ Object (readonly)
Returns the value of attribute item.
157 158 159 |
# File 'lib/sidekiq/api.rb', line 157 def item @item end |
Instance Method Details
#[](name) ⇒ Object
198 199 200 |
# File 'lib/sidekiq/api.rb', line 198 def [](name) @item.send(:[], name) end |
#args ⇒ Object
169 170 171 |
# File 'lib/sidekiq/api.rb', line 169 def args @item['args'] end |
#delete ⇒ Object
Remove this job from the queue.
191 192 193 194 195 196 |
# File 'lib/sidekiq/api.rb', line 191 def delete count = Sidekiq.redis do |conn| conn.lrem("queue:#{@queue}", 0, @value) end count != 0 end |
#enqueued_at ⇒ Object
177 178 179 |
# File 'lib/sidekiq/api.rb', line 177 def enqueued_at Time.at(@item['enqueued_at'] || 0) end |
#jid ⇒ Object
173 174 175 |
# File 'lib/sidekiq/api.rb', line 173 def jid @item['jid'] end |
#klass ⇒ Object
165 166 167 |
# File 'lib/sidekiq/api.rb', line 165 def klass @item['class'] end |
#latency ⇒ Object
185 186 187 |
# File 'lib/sidekiq/api.rb', line 185 def latency Time.now.to_f - @item['enqueued_at'] end |
#queue ⇒ Object
181 182 183 |
# File 'lib/sidekiq/api.rb', line 181 def queue @queue end |