Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deprecation notice that async mode will be renamed async_all in GoodJob v2.0 #339

Merged
merged 1 commit into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/good_job/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def shutdown(timeout: :default, wait: nil)
# Whether in +:async+ execution mode.
# @return [Boolean]
def execute_async?
@configuration.execution_mode == :async ||
@configuration.execution_mode.in?([:async, :async_all]) ||
@configuration.execution_mode == :async_server && in_server_process?
end

Expand Down
15 changes: 13 additions & 2 deletions lib/good_job/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module GoodJob
#
class Configuration
# Valid execution modes.
EXECUTION_MODES = [:async, :async_server, :external, :inline].freeze
EXECUTION_MODES = [:async, :async_all, :async_server, :external, :inline].freeze
# Default number of threads to use per {Scheduler}
DEFAULT_MAX_THREADS = 5
# Default number of seconds between polls for jobs
Expand Down Expand Up @@ -58,7 +58,18 @@ def execution_mode
end

if mode
mode.to_sym
mode_sym = mode.to_sym
if mode_sym == :async
ActiveSupport::Deprecation.warn <<~DEPRECATION
The next major version of GoodJob will redefine the meaning of 'async'
execution mode to be equivalent to 'async_server' and only execute
within the webserver process.

To continue using the v1.0 semantics of 'async', use `async_all` instead.

DEPRECATION
end
mode_sym
elsif Rails.env.development? || Rails.env.test?
:inline
else
Expand Down
10 changes: 9 additions & 1 deletion spec/lib/good_job/adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,22 @@
end

describe '#execute_async?' do
context 'when execution mode async_all' do
context 'when execution mode async' do
let(:adapter) { described_class.new(execution_mode: :async) }

it 'returns true' do
expect(adapter.execute_async?).to eq true
end
end

context 'when execution mode async_all' do
let(:adapter) { described_class.new(execution_mode: :async_all) }

it 'returns true' do
expect(adapter.execute_async?).to eq true
end
end

context 'when execution mode async_server' do
let(:adapter) { described_class.new(execution_mode: :async_server) }

Expand Down