0.0
No commit activity in last 3 years
No release in over 3 years
resque-mission adds Missions (multi-step jobs) to Resque
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1.19
 Project Readme

resque-mission

resque-mission adds Missions (multi-step jobs) to Resque.

Example

require 'resque-mission'

class TestMission < Resque::Plugins::Mission

  # specify the queue (string/symbol)
  queue :test

  attr_reader :a, :b, :c

  # called by create_from_options
  def initialize(a, b, c)
    @a = a
    @b = b
    @c = c
  end

  # implement this to rehydrate state from queue
  # can modify what's passed to queue!(...) to whatever initialize wants
  # eg: fetch an object from db by id, and pass obj to initialize 
  def self.create_from_options(args={})
    new(args['a'], args['b'], args['c'])
  end

  # steps are executed in the order they are declared here
  # each one maps to a method of the same name
  step :step1
  step :step2

  def step1
    sleep 2
    `echo '#{a} #{b} #{c}' > /tmp/step1.$(date -d "today" +"%Y%m%d%H%M%S").log`
  end

  def step2
    sleep 5
    `echo '#{a} #{b} #{c}' > /tmp/step2.$(date -d "today" +"%Y%m%d%H%M%S").log`
  end

end

# enqueue
TestMission.queue!({
  :a => "Mission", 
  :b => "Impossible",
  :c => "Accomplished"
})

Requirements/Dependencies

Contributions

Original implementation (and clever name) by Matthew Lyon.

Wrapping it up and delivering it as a plugin/gem (and maintaining it from here on out) by Troy Howard

Copyright

Copyright © 2013 Troy Howard. See LICENSE for details.