Class: ResqueWeb::Plugins::ResqueScheduler::ActiveJobWrapperTimestampFinder

Inherits:
Object
  • Object
show all
Defined in:
app/models/resque_web/plugins/resque_scheduler/active_job_wrapper_timestamp_finder.rb

Overview

The way ActiveJob works breaks Resque Scheduler’s method for finding the timestamps when jobs have been scheduled. This is because the queue name is stored as a parameter and is not accessible as an instance variable or via a class method. This class is used by the controller to handle the special case.

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ ActiveJobWrapperTimestampFinder

Returns a new instance of ActiveJobWrapperTimestampFinder.



10
11
12
# File 'app/models/resque_web/plugins/resque_scheduler/active_job_wrapper_timestamp_finder.rb', line 10

def initialize(args)
  @args = args
end

Instance Method Details

#active_job_wrapper_class_nameObject



38
39
40
# File 'app/models/resque_web/plugins/resque_scheduler/active_job_wrapper_timestamp_finder.rb', line 38

def active_job_wrapper_class_name
  'ActiveJob::QueueAdapters::ResqueAdapter::JobWrapper'
end

#encoded_search_stringObject



23
24
25
# File 'app/models/resque_web/plugins/resque_scheduler/active_job_wrapper_timestamp_finder.rb', line 23

def encoded_search_string
  Resque.send :encode, hashed_job
end

#hashed_jobObject



27
28
29
30
31
32
# File 'app/models/resque_web/plugins/resque_scheduler/active_job_wrapper_timestamp_finder.rb', line 27

def hashed_job
  Resque.send :job_to_hash_with_queue,
              queue_name,
              active_job_wrapper_class_name,
              @args
end

#performObject



14
15
16
17
18
19
20
21
# File 'app/models/resque_web/plugins/resque_scheduler/active_job_wrapper_timestamp_finder.rb', line 14

def perform
  search_string = "timestamps:#{encoded_search_string}"
  Resque.instance_eval do
    redis.smembers(search_string).map do |key|
      key.tr('delayed:', '').to_i
    end
  end
end

#queue_nameObject



34
35
36
# File 'app/models/resque_web/plugins/resque_scheduler/active_job_wrapper_timestamp_finder.rb', line 34

def queue_name
  @args.first['queue_name']
end