Module: RocketJob::Batch::Throttle
- Extended by:
- ActiveSupport::Concern
- Included in:
- RocketJob::Batch
- Defined in:
- lib/rocket_job/batch/throttle.rb
Overview
Rocket Job Batch Throttling Framework.
Example:
# Do not run any slices for this job when the MySQL slave delay exceeds 5 minutes.
class MyJob < RocketJob::Job
include RocketJob::Batch
# Define a custom mysql throttle
# Prevents all slices from this job from running on the current server.
define_batch_throttle :mysql_throttle_exceeded?
def perform(record)
# ....
end
private
# Returns true if the MySQL slave delay exceeds 5 minutes
def mysql_throttle_exceeded?
status = ActiveRecord::Base.connection.connection.select_one('show slave status')
seconds_delay = Hash(status)['Seconds_Behind_Master'].to_i
seconds_delay >= 300
end
end
Defined Under Namespace
Modules: ClassMethods