Module: RocketJob::Batch::LowerPriority

Extended by:
ActiveSupport::Concern
Defined in:
lib/rocket_job/batch/lower_priority.rb

Overview

Automatically lower the priority for Jobs with a higher record_count.

Note:

- Add `:lower_priority` as a before_batch, but only once the `record_count` has been set.
- If the `record_count` is not set by the time this plugins `before_batch`
is called, then the priority will not be modified.

class SampleJob < RocketJob::Job include RocketJob::Plugins::Batch include RocketJob::Plugins::Batch::LowerPriority

before_batch :upload_data, :lower_priority

def perform(record)
record.reverse
end

private

def upload_data
upload do |stream|
  stream << 'abc'
  stream << 'def'
  stream << 'ghi'
end
end

end