Class: Resqutils::StaleWorkers::WorkerWithStartTime

Inherits:
Object
  • Object
show all
Defined in:
lib/resqutils/stale_workers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(worker, seconds_to_be_considered_stale) ⇒ WorkerWithStartTime

Returns a new instance of WorkerWithStartTime


47
48
49
50
51
# File 'lib/resqutils/stale_workers.rb', line 47

def initialize(worker,seconds_to_be_considered_stale)
  @worker = worker
  @seconds_to_be_considered_stale = seconds_to_be_considered_stale
  @start_time = Time.parse(worker.job["run_at"]) rescue nil
end

Instance Attribute Details

#workerObject (readonly)

Returns the value of attribute worker


46
47
48
# File 'lib/resqutils/stale_workers.rb', line 46

def worker
  @worker
end

Instance Method Details

#stale?Boolean

Returns:

  • (Boolean)

53
54
55
56
# File 'lib/resqutils/stale_workers.rb', line 53

def stale?
  return false if @start_time.nil?
  @start_time <= (Time.now - @seconds_to_be_considered_stale)
end