Class: Jobi::Runner

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/jobi/runner.rb

Instance Method Summary collapse

Methods included from Utils

#constantize, #generate_job_id

Constructor Details

#initialize(payload:) ⇒ Runner

Returns a new instance of Runner.



7
8
9
# File 'lib/jobi/runner.rb', line 7

def initialize(payload:)
  @message = Marshal.load(payload)
end

Instance Method Details

#runObject



11
12
13
14
15
16
17
# File 'lib/jobi/runner.rb', line 11

def run
  job = @message.job_class.new(**@message.args)
  job.run
  job.send(@message.after_run) if @message.after_run

  Jobi.logger.info("Completed in: #{job_duration}")
end