Sha256: d8de9bd9e1b53f02fd46bcd3649e60d82956a6698acceac5f0dd13aecbf8aaba

Contents?: true

Size: 870 Bytes

Versions: 33

Compression:

Stored size: 870 Bytes

Contents

# frozen_string_literal: true

module GoodJob # :nodoc:
  class Notifier # :nodoc:
    # Extends the Notifier to register the process in the database.
    module ProcessRegistration
      extend ActiveSupport::Concern

      included do
        set_callback :listen, :after, :register_process
        set_callback :unlisten, :after, :deregister_process
      end

      # Registers the current process.
      def register_process
        GoodJob::Process.with_connection(connection) do
          next unless Process.migrated?

          GoodJob::Process.cleanup
          @process = GoodJob::Process.register
        end
      end

      # Deregisters the current process.
      def deregister_process
        GoodJob::Process.with_connection(connection) do
          next unless Process.migrated?

          @process&.deregister
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
good_job-2.99.0 lib/good_job/notifier/process_registration.rb
good_job-2.17.1 lib/good_job/notifier/process_registration.rb
good_job-2.17.0 lib/good_job/notifier/process_registration.rb
good_job-2.16.1 lib/good_job/notifier/process_registration.rb
good_job-2.16.0 lib/good_job/notifier/process_registration.rb
good_job-2.15.2 lib/good_job/notifier/process_registration.rb
good_job-2.15.1 lib/good_job/notifier/process_registration.rb
good_job-2.15.0 lib/good_job/notifier/process_registration.rb
good_job-2.14.4 lib/good_job/notifier/process_registration.rb
good_job-2.14.3 lib/good_job/notifier/process_registration.rb
good_job-2.14.2 lib/good_job/notifier/process_registration.rb
good_job-2.14.1 lib/good_job/notifier/process_registration.rb
good_job-2.14.0 lib/good_job/notifier/process_registration.rb
good_job-2.13.2 lib/good_job/notifier/process_registration.rb
good_job-2.13.1 lib/good_job/notifier/process_registration.rb
good_job-2.13.0 lib/good_job/notifier/process_registration.rb
good_job-2.12.2 lib/good_job/notifier/process_registration.rb
good_job-2.12.1 lib/good_job/notifier/process_registration.rb
good_job-2.12.0 lib/good_job/notifier/process_registration.rb
good_job-2.11.3 lib/good_job/notifier/process_registration.rb