Giter VIP home page Giter VIP logo

resque-mission's Introduction

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.

resque-mission's People

Contributors

alunyou avatar thoward avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.