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.
-
#initialize(item, queue_name = nil) ⇒ Job
constructor
A new instance of Job.
- #jid ⇒ Object
- #klass ⇒ Object
- #queue ⇒ Object
Constructor Details
Instance Attribute Details
#item ⇒ Object (readonly)
Returns the value of attribute item.
56 57 58 |
# File 'lib/sidekiq/api.rb', line 56 def item @item end |
Instance Method Details
#[](name) ⇒ Object
89 90 91 |
# File 'lib/sidekiq/api.rb', line 89 def [](name) @item.send(:[], name) end |
#args ⇒ Object
68 69 70 |
# File 'lib/sidekiq/api.rb', line 68 def args @item['args'] end |
#delete ⇒ Object
Remove this job from the queue.
82 83 84 85 86 87 |
# File 'lib/sidekiq/api.rb', line 82 def delete count = Sidekiq.redis do |conn| conn.lrem("queue:#{@queue}", 0, @value) end count != 0 end |
#jid ⇒ Object
72 73 74 |
# File 'lib/sidekiq/api.rb', line 72 def jid @item['jid'] end |
#klass ⇒ Object
64 65 66 |
# File 'lib/sidekiq/api.rb', line 64 def klass @item['class'] end |
#queue ⇒ Object
76 77 78 |
# File 'lib/sidekiq/api.rb', line 76 def queue @queue end |