Skip to content

Commit

Permalink
Add deprecation notice that async mode will be renamed async_all
Browse files Browse the repository at this point in the history
…in GoodJob v2.0 (#339)
  • Loading branch information
bensheldon committed Aug 18, 2021
1 parent ae9adc5 commit 71986bb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
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

0 comments on commit 71986bb

Please sign in to comment.