lib/good_job/notifier.rb in good_job-3.15.14 vs lib/good_job/notifier.rb in good_job-3.16.0
- old
+ new
@@ -1,6 +1,7 @@
# frozen_string_literal: true
+
require 'active_support/core_ext/module/attribute_accessors_per_thread'
require 'concurrent/atomic/atomic_boolean'
require "good_job/notifier/process_heartbeat"
module GoodJob # :nodoc:
@@ -44,11 +45,11 @@
# @!attribute [r] instances
# @!scope class
# List of all instantiated Notifiers in the current process.
# @return [Array<GoodJob::Notifier>, nil]
- cattr_reader :instances, default: [], instance_reader: false
+ cattr_reader :instances, default: Concurrent::Array.new, instance_reader: false
# @!attribute [rw] connection
# @!scope class
# ActiveRecord Connection that has been established for the Notifier.
# @return [ActiveRecord::ConnectionAdapters::AbstractAdapter, nil]
@@ -75,13 +76,12 @@
@listening = Concurrent::AtomicBoolean.new(false)
@connection_errors_count = Concurrent::AtomicFixnum.new(0)
@connection_errors_reported = Concurrent::AtomicBoolean.new(false)
@enable_listening = enable_listening
- self.class.instances << self
-
create_executor
listen
+ self.class.instances << self
end
# Tests whether the notifier is active and has acquired a dedicated database connection.
# @return [true, false, nil]
def connected?