Class: Delayed::Master::JobFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/delayed/master/job_finder.rb

Instance Method Summary collapse

Constructor Details

#initialize(master) ⇒ JobFinder

Returns a new instance of JobFinder.



10
11
12
# File 'lib/delayed/master/job_finder.rb', line 10

def initialize(master)
  @config = master.config
end

Instance Method Details

#ready_jobs(database, setting, limit) ⇒ Object



14
15
16
17
18
# File 'lib/delayed/master/job_finder.rb', line 14

def ready_jobs(database, setting, limit)
  ready_scope(database, setting).limit(limit).pluck(:id, :run_at).map do |id, run_at|
    Job.new(database: database, setting: setting, id: id, run_at: run_at)
  end
end

#recent_jobs(database) ⇒ Object



20
21
22
23
24
# File 'lib/delayed/master/job_finder.rb', line 20

def recent_jobs(database)
  recent_scope(database).order(:run_at).limit(1).pluck(:id, :run_at).map do |id, run_at|
    Job.new(database: database, id: id, run_at: run_at)
  end
end