The project is in a healthy, maintained state
Enqueue just one job with the same key
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.0

Runtime

 Project Readme

Delayed Job Unique

Delayed Job Unique is a Ruby gem that provides an extension to delayed_job_active_record for handling unique jobs in the queue.

Installation

$ bundle add delayed_job_unique

Or add the following line to your application's Gemfile:

gem 'delayed_job_unique'

And then execute:

$ bundle install

Usage

The gem provides a Delayed::Job::enqueue_once class method which will use the unique_key of your job to check for other not failed jobs enqueued under the same key. This provides a simple yet flexible mechanism to finely control the concurrency on each Job class.

If the job was already enqueued it will return false, otherwise it will return the enqueued job instance.

Example

class MyUniqueJob
  def perform
    # Your job logic here
  end

  def unique_key
    # Return a unique key for the job (String)
  end
end

# Enqueue the job only if it's not already in the queue
if Delayed::Job.enqueue_once(MyUniqueJob.new)
  # job enqueued
else
  # job was already enqueued 
end

Development

git clone https://github.com/sinaptia/delayed_job_unique.git
cd delayed_job_uniq
bundle install

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b feature/my-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin feature/my-feature)
  5. Create a new Pull Request