Closed KushalP closed 5 years ago
@KushalP Thanks for opening this issue!
Yup, the idea sounds good. Shouldn't be too hard. We're going to need a migration since we have to add a column and either add/modify an index to cover priority.
Would you like to take a crack at implementing this?
Makes sense. How should the priority
be defined on a Rihanna.Job
level for people implementing their own priority levels?
You asked for the feature... how would you like to use it? :)
A field that could be overridden makes sense: @priorty 10
.
Sounds great. Could be even better as a function:
def priority, do: 10
This has two advantages:
Summary
All jobs are not created equal. Some need to be scheduled earlier than others if there aren't enough workers to work on all of the enqueued jobs. Allow defining a priority against all jobs to make sure that higher priority jobs are scheduled.
An example
You are running a subscription business and have two background jobs defined:
In this example you want to send the email to the customer to make sure they have feedback on the receipt of their subscription. This would take a higher priority over notifying a Slack channel.
Design idea
Create a column
priority (smallint/integer)
that allows defining an integer priority. This can conform to the niceness values used in Linux — lower values are more important. When trying to poll for jobs, order the result bypriority
.