Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A resque plugin which provides a DSL for job steps.
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
Gemfile
Gemfile.lock
LICENSE.txt
README.rdoc
Rakefile
VERSION
init.rb
resque-steps.gemspec

README.rdoc

resque-steps

resque-steps is a resque plugin that provides a DSL for describing your jobs in a series of steps. When one step fails, the resque system allows you to restart the job beginning at that specific step. Previous steps are automatically skipped when they have already been successfully run.

Tested with resque 1.23.0 .

TODO

# Unit Testing
# Support other resque modules.
# Implement it similar to resque-status, where you must implement it as an instance method. 
# Task metadata hooks.
# Allow arbitrary alphanumeric step names
  # Needs a 'step list' instance variable to determine what order to run things in.

Limitations

Currently, using a task with the Steps plugin requires you to provide a Hash to the task as the argument. This hash can be empty or it can have data:

Resque.enqueue(VeryLongTask,{})
Resque.enqueue(VeryLongTask,{ :key => 'value' })

This hash is used to attach step metadata. Eventually the plan is to support arbitrary arguments through a metadata system.

Example

module VeryLongTask
  include Resque::Plugins::Steps
  @queue = ...

  def self.steps(s)
    s.step(1) do |data|
      //perform step 1
      data['whatever'] = 'asdf' //add new data 
      // or data.merge!({...})
    end
    s.step(2) do |data|
      //perform step 2
      // we can use data['whatever'], even if step2 fails and has to be re-run.
    end
    s.step(3) do |data|
      //perform step 3
    end
  end
end

You can queue this task just like any other, using Resque.enqueue.

The series of steps are sorted and this list is sliced based on the previous step attempted.

When working on your jobs, it's best to fix all your steps without changing their numbers.

Copyright

Copyright © 2012 Sheena Artrip. See LICENSE.txt for further details.

Something went wrong with that request. Please try again.