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.
164 165 166 |
# File 'lib/sidekiq/api.rb', line 164 def item @item end |
Instance Method Details
#[](name) ⇒ Object
205 206 207 |
# File 'lib/sidekiq/api.rb', line 205 def [](name) @item.send(:[], name) end |
#args ⇒ Object
176 177 178 |
# File 'lib/sidekiq/api.rb', line 176 def args @item['args'] end |
#delete ⇒ Object
Remove this job from the queue.
198 199 200 201 202 203 |
# File 'lib/sidekiq/api.rb', line 198 def delete count = Sidekiq.redis do |conn| conn.lrem("queue:#{@queue}", 1, @value) end count != 0 end |
#enqueued_at ⇒ Object
184 185 186 |
# File 'lib/sidekiq/api.rb', line 184 def enqueued_at Time.at(@item['enqueued_at'] || 0).utc end |
#jid ⇒ Object
180 181 182 |
# File 'lib/sidekiq/api.rb', line 180 def jid @item['jid'] end |
#klass ⇒ Object
172 173 174 |
# File 'lib/sidekiq/api.rb', line 172 def klass @item['class'] end |
#latency ⇒ Object
192 193 194 |
# File 'lib/sidekiq/api.rb', line 192 def latency Time.now.to_f - @item['enqueued_at'] end |
#queue ⇒ Object
188 189 190 |
# File 'lib/sidekiq/api.rb', line 188 def queue @queue end |