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.
187 188 189 |
# File 'lib/sidekiq/api.rb', line 187 def item @item end |
Instance Method Details
#[](name) ⇒ Object
228 229 230 |
# File 'lib/sidekiq/api.rb', line 228 def [](name) @item.__send__(:[], name) end |
#args ⇒ Object
199 200 201 |
# File 'lib/sidekiq/api.rb', line 199 def args @item['args'] end |
#delete ⇒ Object
Remove this job from the queue.
221 222 223 224 225 226 |
# File 'lib/sidekiq/api.rb', line 221 def delete count = Sidekiq.redis do |conn| conn.lrem("queue:#{@queue}", 1, @value) end count != 0 end |
#enqueued_at ⇒ Object
207 208 209 |
# File 'lib/sidekiq/api.rb', line 207 def enqueued_at Time.at(@item['enqueued_at'] || 0).utc end |
#jid ⇒ Object
203 204 205 |
# File 'lib/sidekiq/api.rb', line 203 def jid @item['jid'] end |
#klass ⇒ Object
195 196 197 |
# File 'lib/sidekiq/api.rb', line 195 def klass @item['class'] end |
#latency ⇒ Object
215 216 217 |
# File 'lib/sidekiq/api.rb', line 215 def latency Time.now.to_f - @item['enqueued_at'] end |
#queue ⇒ Object
211 212 213 |
# File 'lib/sidekiq/api.rb', line 211 def queue @queue end |