Updated

config/initializers / delayed_job_config.rb

A
58 lines of codes
2 methods
10.3 complexity/method
7 churn
20.66 complexity
0 duplications
Delayed::Worker.max_attempts = 15 Delayed::Worker.max_run_time = 6.hours Delayed::Worker.default_priority = 100 require 'active_job/queue_adapters/delayed_job_adapter' # We patch in the display_name method to the Delayed Job queue adapter # so that all the jobs aren't aggregated under one name in AppSignal. module ActiveJob module QueueAdapters class DelayedJobAdapter class JobWrapper
  1. ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper has no descriptive comment
def display_name if job_data['job_class'] == 'ActionMailer::DeliveryJob'
  1. ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper#display_name calls 'job_data['job_class']' 2 times Locations: 0 1
"#{job_data['arguments'][0]}##{job_data['arguments'][1]}"
  1. ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper#display_name calls 'job_data['arguments']' 2 times
else "#{job_data['job_class']}#perform"
  1. ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper#display_name calls 'job_data['job_class']' 2 times Locations: 0 1
end end end end end end # Override the default after_fork method on Delayed::Backend::ActiveRecord::Job # to restart the Appsignal agent when the worker is forked. module Delayed module Backend module ActiveRecord class Job < ::ActiveRecord::Base
  1. Delayed::Backend::ActiveRecord::Job has no descriptive comment
def self.after_fork # Worker specific setup for Rails 4.1+ # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot ::ActiveRecord::Base.establish_connection # Let AppSignal know that a worker process has been forked ::Appsignal.forked if defined?(::Appsignal) && ::Appsignal.config.active? end end end end end # Add a before_save callback to set the priority based on the queue name module Delayed module Backend module ActiveRecord class Job < ::ActiveRecord::Base
  1. Delayed::Backend::ActiveRecord::Job has no descriptive comment
QUEUE_PRIORITIES = { "highest_priority" => 0, "high_priority" => 10, "low_priority" => 50 } QUEUE_PRIORITIES.default = 25 before_create do self.priority = QUEUE_PRIORITIES[queue] end end end end end