Sha256: 2957e81e3c26d5447895dcf8b1b9fb74ca622d6cf80babf8acea4123968d6140

Contents?: true

Size: 1.01 KB

Versions: 12

Compression:

Stored size: 1.01 KB

Contents

module ActiveJob::Querying
  extend ActiveSupport::Concern

  included do
    # ActiveJob will use pagination internally when fetching relations of jobs. This
    # parameter sets the max amount of jobs to fetch in each data store query.
    class_attribute :default_page_size, default: 1000
  end

  class_methods do
    # Returns the list of queues.
    #
    # See +ActiveJob::Queues+
    def queues
      ActiveJob::Queues.new(fetch_queues)
    end

    def jobs
      ActiveJob::JobsRelation.new(queue_adapter: queue_adapter, default_page_size: default_page_size)
    end

    private
      def fetch_queues
        queue_adapter.queues.collect do |queue|
          ActiveJob::Queue.new(queue[:name], size: queue[:size], active: queue[:active], queue_adapter: queue_adapter)
        end
      end
  end

  def queue
    self.class.queues[queue_name]
  end

  # Top-level query methods added to `ActiveJob`
  module Root
    def queues
      ActiveJob::Base.queues
    end

    def jobs
      ActiveJob::Base.jobs
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
mission_control-jobs-0.6.0 lib/active_job/querying.rb
mission_control-jobs-0.5.0 lib/active_job/querying.rb
mission_control-jobs-0.4.0 lib/active_job/querying.rb
mission_control-jobs-0.3.3 lib/active_job/querying.rb
mission_control-jobs-0.3.2 lib/active_job/querying.rb
mission_control-jobs-0.3.1 lib/active_job/querying.rb
mission_control-jobs-0.3.0 lib/active_job/querying.rb
mission_control-jobs-0.2.2 lib/active_job/querying.rb
mission_control-jobs-0.2.1 lib/active_job/querying.rb
mission_control-jobs-0.2.0 lib/active_job/querying.rb
mission_control-jobs-0.1.1 lib/active_job/querying.rb
mission_control-jobs-0.1.0 lib/active_job/querying.rb