Class: Wurk::Work
- Inherits:
-
Object
- Object
- Wurk::Work
- Defined in:
- lib/wurk/work_set.rb
Overview
One in-flight job. The payload field is the raw JSON the processor
is currently executing; job lazily wraps it in a JobRecord so
downstream code can read class/args/jid without re-parsing.
Spec: docs/target/sidekiq-free.md §19.7.
Instance Attribute Summary collapse
-
#process_id ⇒ Object
readonly
Returns the value of attribute process_id.
-
#thread_id ⇒ Object
readonly
Returns the value of attribute thread_id.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #dig(*keys) ⇒ Object
-
#initialize(pid, tid, hsh) ⇒ Work
constructor
A new instance of Work.
- #job ⇒ Object
- #payload ⇒ Object
- #queue ⇒ Object
-
#raw(name) ⇒ Object
Sidekiq 7's field readers, gone from 8.
-
#run_at ⇒ Object
Float epoch seconds → Time.
Constructor Details
#initialize(pid, tid, hsh) ⇒ Work
Returns a new instance of Work.
92 93 94 95 96 |
# File 'lib/wurk/work_set.rb', line 92 def initialize(pid, tid, hsh) @process_id = pid @thread_id = tid @hsh = hsh end |
Instance Attribute Details
#process_id ⇒ Object (readonly)
Returns the value of attribute process_id.
90 91 92 |
# File 'lib/wurk/work_set.rb', line 90 def process_id @process_id end |
#thread_id ⇒ Object (readonly)
Returns the value of attribute thread_id.
90 91 92 |
# File 'lib/wurk/work_set.rb', line 90 def thread_id @thread_id end |
Instance Method Details
#[](key) ⇒ Object
104 |
# File 'lib/wurk/work_set.rb', line 104 def [](key) = @hsh[key] |
#dig(*keys) ⇒ Object
105 |
# File 'lib/wurk/work_set.rb', line 105 def dig(*keys) = @hsh.dig(*keys) |
#job ⇒ Object
113 114 115 |
# File 'lib/wurk/work_set.rb', line 113 def job @job ||= JobRecord.new(payload) end |
#payload ⇒ Object
99 |
# File 'lib/wurk/work_set.rb', line 99 def payload = @hsh['payload'] |
#queue ⇒ Object
98 |
# File 'lib/wurk/work_set.rb', line 98 def queue = @hsh['queue'] |
#raw(name) ⇒ Object
Sidekiq 7's field readers, gone from 8. Unparsed, as they were there:
work['payload'] is the JSON String.
103 |
# File 'lib/wurk/work_set.rb', line 103 def raw(name) = @hsh[name] |
#run_at ⇒ Object
Float epoch seconds → Time. Heartbeat writes run_at as Float, so
we don't have to handle the dual ms/secs format JobRecord does.
109 110 111 |
# File 'lib/wurk/work_set.rb', line 109 def run_at ::Time.at(@hsh['run_at']) end |