Skip to content

Creating a Jobby Freelancer

HHRy edited this page Sep 13, 2010 · 1 revision

As Jobby Rails was built to be a drop-in replacement for the version of BackgrounDRb we were running. As such, we designed worker classes called Freelancers to instruct Jobby on how to run tasks required.

A freelancer looks like:

  class YourNewFreelancer < Jobby::Freelancer
    def work
      # Your Work Here
    end
  end

All Freelancers ultimately inherit from Jobby::Freelancer and must always implement a work method. If you don’t have a work method in your freelancer a Jobby::InvalidFreelancer exception will be raised.

Any exceptions raised during the execution of your work method will be handled by Jobby::Freelancer and ensure that appropriate logging takes place and that the status of the associated Jobby::Job is updated.

Freelancers provide a bunch of convenience methods to allow you to talk to the underlying Jobby::Job being executed so that you can set some values for communicating back to your application:

message= 			Sets a progress message for your application
total_stages=		        Total Steps to go through (used for progress bar)
current_stage=		        Current step being executed (used for progress bar)

A full detail of the methods provided by Jobby::Freelancer is available in the RDoc archive online.

Clone this wiki locally