diff --git a/lib/good_job/adapter.rb b/lib/good_job/adapter.rb index 241688e9d..48e3ac9dd 100644 --- a/lib/good_job/adapter.rb +++ b/lib/good_job/adapter.rb @@ -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 diff --git a/lib/good_job/configuration.rb b/lib/good_job/configuration.rb index 74d63dd16..5e48a0e02 100644 --- a/lib/good_job/configuration.rb +++ b/lib/good_job/configuration.rb @@ -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 @@ -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 diff --git a/spec/lib/good_job/adapter_spec.rb b/spec/lib/good_job/adapter_spec.rb index 612ea0fcb..abfb30e20 100644 --- a/spec/lib/good_job/adapter_spec.rb +++ b/spec/lib/good_job/adapter_spec.rb @@ -80,7 +80,7 @@ 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 @@ -88,6 +88,14 @@ 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) }