GithubHelp home page GithubHelp logo

resque_solo's Introduction

ResqueSolo

Gem Version Build Status

ResqueSolo is a resque plugin to add unique jobs to resque.

It is a re-write of resque-loner.

It requires resque 1.25 and works with ruby 2.0 and later.

It removes the dependency on Resque::Helpers, which is deprecated for resque 2.0.

Install

Add the gem to your Gemfile:

gem 'resque_solo'

Usage

class UpdateCat
  include Resque::Plugins::UniqueJob
  @queue = :cats

  def self.perform(cat_id)
    # do something
  end
end

If you attempt to queue a unique job multiple times, it is ignored:

Resque.enqueue UpdateCat, 1
=> "OK"
Resque.enqueue UpdateCat, 1
=> "EXISTED"
Resque.enqueue UpdateCat, 1
=> "EXISTED"
Resque.size :cats
=> 1
Resque.enqueued? UpdateCat, 1
=> true
Resque.enqueued_in? :dogs, UpdateCat, 1
=> false

Options

lock_after_execution_period

By default, lock_after_execution_period is 0 and enqueued? becomes false as soon as the job is being worked on.

The lock_after_execution_period setting can be used to delay when the unique job key is deleted (i.e. when enqueued? becomes false). For example, if you have a long-running unique job that takes around 10 seconds, and you don't want to requeue another job until you are sure it is done, you could set lock_after_execution_period = 20. Or if you never want to run a long running job more than once per minute, set lock_after_execution_period = 60.

resque_solo's People

Contributors

teeparham avatar

Watchers

James Cloos avatar Oren Forer 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.