lib/good_job/adapter.rb in good_job-3.15.14 vs lib/good_job/adapter.rb in good_job-3.16.0
- old
+ new
@@ -1,16 +1,17 @@
# frozen_string_literal: true
+
module GoodJob
#
# ActiveJob Adapter.
#
class Adapter
# @!attribute [r] instances
# @!scope class
# List of all instantiated Adapters in the current process.
# @return [Array<GoodJob::Adapter>, nil]
- cattr_reader :instances, default: [], instance_reader: false
+ cattr_reader :instances, default: Concurrent::Array.new, instance_reader: false
# @param execution_mode [Symbol, nil] specifies how and where jobs should be executed. You can also set this with the environment variable +GOOD_JOB_EXECUTION_MODE+.
#
# - +:inline+ executes jobs immediately in whatever process queued them (usually the web server process). This should only be used in test and development environments.
# - +:external+ causes the adapter to enqueue jobs, but not execute them. When using this option (the default for production environments), you'll need to use the command-line tool to actually execute your jobs.
@@ -27,11 +28,11 @@
def initialize(execution_mode: nil, _capsule: GoodJob.capsule) # rubocop:disable Lint/UnderscorePrefixedVariableName
@_execution_mode_override = execution_mode
GoodJob::Configuration.validate_execution_mode(@_execution_mode_override) if @_execution_mode_override
@capsule = _capsule
- self.class.instances << self
start_async if GoodJob.async_ready?
+ self.class.instances << self
end
# Enqueues the ActiveJob job to be performed.
# For use by Rails; you should generally not call this directly.
# @param active_job [ActiveJob::Base] the job to be enqueued from +#perform_later+