Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Job priority labels #17

Open
bradgessler opened this issue May 12, 2015 · 0 comments
Open

Job priority labels #17

bradgessler opened this issue May 12, 2015 · 0 comments
Labels

Comments

@bradgessler
Copy link
Contributor

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) # 2147483648

The 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
end

if a priority is not specified from the list of priorities in the configuration, an exception should be raised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant