Class: SidekiqUniqueJobs::TimeoutCalculator

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq_unique_jobs/timeout_calculator.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item) ⇒ TimeoutCalculator

Returns a new instance of TimeoutCalculator.


9
10
11
# File 'lib/sidekiq_unique_jobs/timeout_calculator.rb', line 9

def initialize(item)
  @item = item
end

Class Method Details

.for_item(item) ⇒ Object


5
6
7
# File 'lib/sidekiq_unique_jobs/timeout_calculator.rb', line 5

def self.for_item(item)
  new(item)
end

Instance Method Details

#secondsObject

Raises:

  • (NotImplementedError)

19
20
21
# File 'lib/sidekiq_unique_jobs/timeout_calculator.rb', line 19

def seconds
  raise NotImplementedError
end

#time_until_scheduledObject


13
14
15
16
17
# File 'lib/sidekiq_unique_jobs/timeout_calculator.rb', line 13

def time_until_scheduled
  scheduled = item[AT_KEY]
  return 0 unless scheduled
  (Time.at(scheduled) - Time.now.utc).to_i
end

#worker_classObject


31
32
33
# File 'lib/sidekiq_unique_jobs/timeout_calculator.rb', line 31

def worker_class
  @worker_class ||= SidekiqUniqueJobs.worker_class_constantize(item[CLASS_KEY])
end

#worker_class_queue_lock_expirationObject


23
24
25
# File 'lib/sidekiq_unique_jobs/timeout_calculator.rb', line 23

def worker_class_queue_lock_expiration
  worker_class_expiration_for QUEUE_LOCK_TIMEOUT_KEY
end

#worker_class_run_lock_expirationObject


27
28
29
# File 'lib/sidekiq_unique_jobs/timeout_calculator.rb', line 27

def worker_class_run_lock_expiration
  worker_class_expiration_for RUN_LOCK_TIMEOUT_KEY
end