Module: Ruote::Resque::Job

Defined in:
lib/ruote/resque/job.rb

Overview

Include this module inside your Resque jobs to enable them to respond to Ruote.

  • Note that the arity should be 1 for the self.perform method.
  • The workitem will be sent as a Hash. (via Ruote::Workitem#to_h)

Examples:

class MyAwesomeJob
  extend Ruote::Resque::Job

  def self.perform(workitem)
    workitem['fields']['awesome'] = true
  end
end

Instance Method Summary collapse

Instance Method Details

#after_perform_reply_to_ruote(workitem) ⇒ void

This method returns an undefined value.

after_perform hook to send a reply to the Ruote process.

Parameters:

  • workitem (Hash)

    the workitem sent to the current Job



25
26
27
# File 'lib/ruote/resque/job.rb', line 25

def after_perform_reply_to_ruote(workitem)
  Ruote::Resque.reply(workitem)
end

#on_failure_reply_to_ruote(exception, workitem) ⇒ void

This method returns an undefined value.

on_failure hook to send a reply to the Ruote process. Will collect the exception details and send them along.

Parameters:

  • exception (Exception)

    the raised exception

  • workitem (Hash)

    the workitem sent to the current Job. TODO: this may be mutated from the original workitem, handle it.



35
36
37
38
39
40
41
42
# File 'lib/ruote/resque/job.rb', line 35

def on_failure_reply_to_ruote(exception, workitem)

  klass = exception.class.to_s
  message = exception.message
  backtrace = exception.backtrace

  Ruote::Resque.reply(klass, message, backtrace, workitem)
end