48 lines
1.1 KiB
Ruby
48 lines
1.1 KiB
Ruby
# typed: strict
|
|
class ApplicationJob < ActiveJob::Base
|
|
extend T::Sig
|
|
extend T::Helpers
|
|
|
|
abstract!
|
|
|
|
include GoodJob::ActiveJobExtensions::Concurrency
|
|
include HasColorLogger
|
|
|
|
retry_on(
|
|
StandardError,
|
|
wait: :polynomially_longer,
|
|
attempts: :unlimited,
|
|
) do |job, exception|
|
|
job.logger.error(
|
|
"error: #{exception.message}\n#{exception.backtrace.join("\n")}",
|
|
)
|
|
end
|
|
|
|
@ignore_signature_args = T.let([], T.nilable(T::Array[Symbol]))
|
|
|
|
sig { params(args: Symbol).returns(T::Array[Symbol]) }
|
|
def self.ignore_signature_args(*args)
|
|
@ignore_signature_args ||= []
|
|
@ignore_signature_args.concat(args)
|
|
@ignore_signature_args
|
|
end
|
|
|
|
# collect all ignore_signature_args from all superclasses
|
|
sig { returns(T::Array[Symbol]) }
|
|
def self.gather_ignore_signature_args
|
|
args = T.let(%i[_aj_symbol_keys _aj_ruby2_keywords], T::Array[Symbol])
|
|
|
|
klass = T.let(self, T.class_of(ApplicationJob))
|
|
loop do
|
|
args += klass.ignore_signature_args
|
|
if (superklass = klass.superclass) && superklass < ApplicationJob
|
|
klass = superklass
|
|
else
|
|
break
|
|
end
|
|
end
|
|
|
|
args.uniq.sort
|
|
end
|
|
end
|