Module: ActiveJob::Debounce::Concern

Extended by:
ActiveSupport::Concern
Defined in:
lib/activejob/debounce/concern.rb

Overview

Include this concern in your ActiveJob classes to add debouncing behavior.

When multiple calls to perform_debounce are made with the same arguments within the debounce window, only ONE job will be queued and executed.

Works with any ActiveJob backend: Sidekiq, GoodJob, Solid Queue, Resque, etc.

Examples:

Basic usage

class SyncUserJob < ApplicationJob
  include ActiveJob::Debounce::Concern

  debounce_for 30.seconds

  def perform(user_id)
    User.find(user_id).sync_to_crm
  end
end

# Call it multiple times - only one job executes
10.times { SyncUserJob.perform_debounce(user.id) }