Class: Wurk::Work

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_idObject (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_idObject (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

#jobObject



107
108
109
# File 'lib/wurk/work_set.rb', line 107

def job
  @job ||= JobRecord.new(payload)
end

#payloadObject



99
# File 'lib/wurk/work_set.rb', line 99

def payload = @hsh['payload']

#queueObject



98
# File 'lib/wurk/work_set.rb', line 98

def queue   = @hsh['queue']

#run_atObject

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