Module: SidekiqAdminEnquerer
- Defined in:
- lib/sidekiq_admin_enquerer.rb,
lib/sidekiq_admin_enquerer/version.rb
Overview
Defined Under Namespace
Modules: WebApp
Constant Summary collapse
- JOB_SKIP_LIST =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%w[ Sidekiq::Extensions::DelayedModel Sidekiq::Extensions::DelayedMailer Sidekiq::Extensions::DelayedClass ApplicationJob ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper ].freeze
- VERSION =
'0.1.2'
Class Method Summary collapse
- .find_job(job_name) ⇒ Class<ActiveJob::Base>, Class<Sidekiq::Worker> private
- .jobs ⇒ Array<Class<ActiveJob::Base>,Class<Sidekiq::Worker>> private
- .load ⇒ void
-
.run_job(job, params) ⇒ void
private
rubocop:disable Metrics/AbcSize.
Class Method Details
.find_job(job_name) ⇒ Class<ActiveJob::Base>, Class<Sidekiq::Worker>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
41 42 43 |
# File 'lib/sidekiq_admin_enquerer.rb', line 41 def find_job(job_name) jobs.find { _1.name == job_name || _1.to_s == job_name } end |
.jobs ⇒ Array<Class<ActiveJob::Base>,Class<Sidekiq::Worker>>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 29 30 31 32 33 34 |
# File 'lib/sidekiq_admin_enquerer.rb', line 26 def jobs Rails.application.eager_load! ObjectSpace.each_object(Class).select do |job_klass| next if job_klass.singleton_class? next if JOB_SKIP_LIST.any? { job_klass.to_s.include?(_1) } job_klass < ActiveJob::Base || job_klass.included_modules.include?(Sidekiq::Worker) end end |
.load ⇒ void
This method returns an undefined value.
83 84 85 86 87 88 |
# File 'lib/sidekiq_admin_enquerer.rb', line 83 def load if defined?(Sidekiq::Web) Sidekiq::Web.register(SidekiqAdminEnquerer::WebApp) Sidekiq::Web.tabs['Enquerer'] = 'enquerer' end end |
.run_job(job, params) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
rubocop:disable Metrics/AbcSize
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/sidekiq_admin_enquerer.rb', line 53 def run_job(job, params) # TODO: rework with attribute analysis job_perform_method = params['perform_method'] job_params = params[job_perform_method] || {} # NOTE: {} means that no parameters were passed job.respond_to?(:sidekiq_options) ? job.['queue'].to_s : 'default' if params['submit'] == 'enqueue' case when job < ActiveJob::Base job.perform_later(*job_params.values) when job_klass.included_modules.include?(Sidekiq::Worker) Sidekiq::Client.enqueue_to(queue, job, *job_params.values) end elsif params['submit'] == 'schedule' case when job < ActiveJob::Base job.set(wait: params['enqueue_in'].to_i.seconds).perform_later(*job_params.values) when job_klass.included_modules.include?(Sidekiq::Worker) Sidekiq::Client.enqueue_to_in( queue, params['enqueue_in'].to_i.seconds, job, *job_params.values ) end end end |