Sha256: f19aeecc3ab53af5a0d683dd124f7ba6cba71281ecae8149d72ee234bc5db887

Contents?: true

Size: 956 Bytes

Versions: 8

Compression:

Stored size: 956 Bytes

Contents

# TODO: These (or a version of them) should be moved to +ActiveJob::Core+
# and related concerns when upstreamed.
module ActiveJob::Executing
  extend ActiveSupport::Concern

  included do
    attr_accessor :raw_data, :position, :finished_at, :blocked_by, :blocked_until, :worker_id, :started_at, :status
    attr_reader :serialized_arguments

    thread_cattr_accessor :current_queue_adapter
  end

  class_methods do
    def queue_adapter
      ActiveJob::Base.current_queue_adapter || super
    end
  end

  def retry
    ActiveJob.jobs.failed.retry_job(self)
  end

  def discard
    jobs_relation_for_discarding.discard_job(self)
  end

  def dispatch
    ActiveJob.jobs.blocked.dispatch_job(self)
  end

  private
    def jobs_relation_for_discarding
      case status
      when :failed  then ActiveJob.jobs.failed
      when :pending then ActiveJob.jobs.pending.where(queue_name: queue_name)
      else
        ActiveJob.jobs
      end
    end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mission_control-jobs-0.4.0 lib/active_job/executing.rb
mission_control-jobs-0.3.3 lib/active_job/executing.rb
mission_control-jobs-0.3.2 lib/active_job/executing.rb
mission_control-jobs-0.3.1 lib/active_job/executing.rb
mission_control-jobs-0.3.0 lib/active_job/executing.rb
mission_control-jobs-0.2.2 lib/active_job/executing.rb
mission_control-jobs-0.2.1 lib/active_job/executing.rb
mission_control-jobs-0.2.0 lib/active_job/executing.rb