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
-
#initialize(pid, tid, hsh) ⇒ Work
constructor
A new instance of Work.
- #job ⇒ Object
- #payload ⇒ Object
- #queue ⇒ Object
-
#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
#job ⇒ Object
107 108 109 |
# File 'lib/wurk/work_set.rb', line 107 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'] |
#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.
103 104 105 |
# File 'lib/wurk/work_set.rb', line 103 def run_at ::Time.at(@hsh['run_at']) end |