lib/good_job/capsule.rb in good_job-3.15.14 vs lib/good_job/capsule.rb in good_job-3.16.0
- old
+ new
@@ -1,24 +1,25 @@
# frozen_string_literal: true
+
module GoodJob
# A GoodJob::Capsule contains the resources necessary to execute jobs, including
# a {GoodJob::Scheduler}, {GoodJob::Poller}, {GoodJob::Notifier}, and {GoodJob::CronManager}.
# GoodJob creates a default capsule on initialization.
class Capsule
# @!attribute [r] instances
# @!scope class
# List of all instantiated Capsules in the current process.
# @return [Array<GoodJob::Capsule>, nil]
- cattr_reader :instances, default: [], instance_reader: false
+ cattr_reader :instances, default: Concurrent::Array.new, instance_reader: false
# @param configuration [GoodJob::Configuration] Configuration to use for this capsule.
def initialize(configuration: GoodJob.configuration)
- self.class.instances << self
@configuration = configuration
-
@startable = true
@running = false
@mutex = Mutex.new
+
+ self.class.instances << self
end
# Start the capsule once. After a shutdown, {#restart} must be used to start again.
# @return [nil, Boolean] Whether the capsule was started.
def start(force: false)