No commit activity in last 3 years
No release in over 3 years
A Resque plugin. If you want only one instance of your job running at a time, but want to re-enqueue rejected jobs, extend it with this module. For example: class UpdateNetworkGraph extend Resque::Jobs::RetryOnLocked def self.perform(repo_id) heavy_lifting end end
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Resque Lock

A Resque plugin. Requires Resque 1.7.0.

This plugin is a modification of defunkt's resque-lock plugin located at https://github.com/defunkt/resque-lock

All credit goes to defunkt.

If you want only one instance of your job running at a time, but to also re-enqueue rejected jobs, extend it with this module.

For example:

require 'resque/plugins/retry_on_lock'

class UpdateNetworkGraph
  extend Resque::Plugins::RetryOnLock

  def self.perform(repo_id)
    heavy_lifting
  end
end

While other UpdateNetworkGraph jobs will be placed on the queue, the Locked class will check Redis to see if any others are executing with the same arguments before beginning. If another is executing the job will be re-enqueued.

If you want to define the key yourself you can override the lock class method in your subclass, e.g.

class UpdateNetworkGraph
  extend Resque::Plugins::RetryOnLock

  Run only one at a time, regardless of repo_id.
  def self.lock(repo_id)
    "network-graph"
  end

  def self.perform(repo_id)
    heavy_lifting
  end
end

The above modification will ensure only one job of class UpdateNetworkGraph is running at a time, regardless of the repo_id. Normally a job is locked using a combination of its class name and arguments.