mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00

c685d6928c
has introduced an exception that is raised on an attempt to include Sidekiq::Worker to an ActiveJob::Base descendant. That was done in order to prevent options not supported by ActiveJob, specifically `queue`. See https://github.com/mperham/sidekiq/issues/2424 Support for `set` was added later on, including the setting of `retry` from ActiveJob.d6538b0b4f
This change bridges the gap by allowing ActiveJob::Base descendants to include `Sidekiq::Options` and use `retry` option of `sidekiq_options`, and also `sidekiq_retry_in`, and `sidekiq_retries_exhausted`.
25 lines
770 B
Ruby
25 lines
770 B
Ruby
# frozen_string_literal: true
|
|
require_relative 'helper'
|
|
require 'active_job'
|
|
|
|
describe 'ActiveJob' do
|
|
it 'does not allow Sidekiq::Worker in AJ::Base classes' do
|
|
ex = assert_raises ArgumentError do
|
|
Class.new(ActiveJob::Base) do
|
|
include Sidekiq::Worker
|
|
end
|
|
end
|
|
assert_includes ex.message, "can only include Sidekiq::Worker::Options"
|
|
end
|
|
|
|
it 'allows Sidekiq::Options in AJ::Base classes' do
|
|
Class.new(ActiveJob::Base) do
|
|
include Sidekiq::Worker::Options
|
|
sidekiq_options retry: true
|
|
sidekiq_retry_in { |count, _exception| count * 10 }
|
|
sidekiq_retries_exhausted do |msg, _exception|
|
|
Sidekiq.logger.warn "Failed #{msg['class']} with #{msg['args']}: #{msg['error_message']}"
|
|
end
|
|
end
|
|
end
|
|
end
|