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

Feature: task priority (RabbitMQ) #392

Merged
merged 1 commit into from
May 26, 2024
Merged

Feature: task priority (RabbitMQ) #392

merged 1 commit into from
May 26, 2024

Conversation

runabol
Copy link
Owner

@runabol runabol commented May 25, 2024

Adds support for task priority when using RabbitMQ as a broker.

This features builds on RabbitMQ support for priority queues: https://www.rabbitmq.com/docs/priority

This change does require re-creating the task queues (by simply deleting them and letting Tork re-create them).

There is also a DB schema change adding the priority field to the tasks table:

alter table tasks add priority int default 0

To use priority in your jobs set the priority property on the task (values 1-9). Higher values indicate higher priority. Example:

- name: my first task
  image: alpine:3.18.3
  run: sleep 3
  priority: 1

This task will execute as a priority over tasks with no priority defined.

You can also set the default priority for a task at the job level:

name: my job
defaults:
  priority: 1
tasks:
- name: my first task
  image: alpine:3.18.3
  run: sleep 3

Workers that are already processing a task -- even a lower priority task -- will complete the task before considering any prioritized tasks.

@runabol runabol changed the title Feature: task priority Feature: task priority (RabbitMQ) May 25, 2024
@runabol runabol mentioned this pull request May 25, 2024
@runabol runabol merged commit 10d836e into main May 26, 2024
5 checks passed
@runabol runabol deleted the priority branch May 26, 2024 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant