Class: Kindly::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/kindly/runner.rb

Instance Method Summary collapse

Constructor Details

#initializeRunner

Returns a new instance of Runner.



6
7
8
9
# File 'lib/kindly/runner.rb', line 6

def initialize
  @queue = Queue.new
  @db = DB.new
end

Instance Method Details

#run(job_name) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/kindly/runner.rb', line 11

def run(job_name)
  job_id = @queue.pop(job_name)
  if job_id.nil?
    puts "No pending requests for #{job_name}."
    return false
  end

  job = @db.fetch_job(job_name, job_id)
  run_job(job)

  job.respond_to?(:output) ? job.output : {}
end