-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
Description
Job priorities currently live in the Jobs class at https://github.com/polleverywhere/quebert/blob/multiple-tubes/lib/quebert/job.rb#L11-17 in a way that's specific to the Beanstalkd backend. Move priorities into something that looks like Set that has a concept of highest and lowest priority. For example:
pri = Quebert::Prioties.new(%w[high medium low])
pri.highest # "high"
pri.lowest # "low"
pri.to_a # ['high', 'medium', 'low']
pri.lowest.escalate # 'low'
pri.to_a # ['high', 'low', 'medium']
pri.lowest # 'medium'
pri['high'].relative_position_between(0..2**32) # 2147483648The backend that's using priorities can figure out the math needed to schedule a job as high or low priority based on its relative position. Beanstalkd would use 2**32 for low-priority jobs and 0 for high priority jobs.
A job would specify its priority via:
class ImportantJob < Quebert::Job
def priority
'high'
end
endif a priority is not specified from the list of priorities in the configuration, an exception should be raised.