Module: RocketJob::Plugins::Singleton

Extended by:
ActiveSupport::Concern
Included in:
Jobs::DirmonJob, Jobs::HousekeepingJob
Defined in:
lib/rocket_job/plugins/singleton.rb

Overview

Prevent this job from being saved if another is running, queued, or paused.

Instance Method Summary collapse

Instance Method Details

#rocket_job_singleton_active?Boolean

Returns [true|false] whether another instance of this job is already active

Returns:

  • (Boolean)


14
15
16
# File 'lib/rocket_job/plugins/singleton.rb', line 14

def rocket_job_singleton_active?
  self.class.where(:state.in => %i[running queued], :id.ne => id).exists?
end