-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #195 from reef-technologies/dead-letter-queue
Add dead letter queue support
- Loading branch information
Showing
8 changed files
with
139 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...roject_name}}/{{cookiecutter.django_default_app_name}}/management/commands/flush_queue.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from django.core.management.base import BaseCommand | ||
|
||
from {{cookiecutter.django_project_name}}.celery import flush_tasks, get_num_tasks_in_queue | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Flush task queue." | ||
|
||
def add_arguments(self, parser) -> None: | ||
parser.add_argument("queue", type=str, help="Queue name to flush") | ||
|
||
def handle(self, *args, **kwargs): | ||
queue_name = kwargs["queue"] | ||
|
||
num_tasks = get_num_tasks_in_queue(queue_name) | ||
self.stdout.write(f"Found {num_tasks} tasks in '{queue_name}' queue") | ||
if not num_tasks: | ||
return | ||
|
||
flush_tasks(queue_name) | ||
self.stdout.write("All done") |
23 changes: 23 additions & 0 deletions
23
...project_name}}/{{cookiecutter.django_default_app_name}}/management/commands/move_tasks.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from django.core.management.base import BaseCommand | ||
|
||
from {{cookiecutter.django_project_name}}.celery import get_num_tasks_in_queue, move_tasks | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Reschedule dead letter tasks." | ||
|
||
def add_arguments(self, parser) -> None: | ||
parser.add_argument("source_queue", type=str, help="Source queue name") | ||
parser.add_argument("destination_queue", type=str, help="Destination queue name") | ||
|
||
def handle(self, *args, **kwargs): | ||
source_queue = kwargs["source_queue"] | ||
destination_queue = kwargs["destination_queue"] | ||
|
||
num_tasks = get_num_tasks_in_queue(source_queue) | ||
self.stdout.write(f"Found {num_tasks} tasks in '{source_queue}' queue") | ||
if not num_tasks: | ||
return | ||
|
||
move_tasks(source_queue, destination_queue) | ||
self.stdout.write("All done") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 20 additions & 2 deletions
22
...rc/{{cookiecutter.django_project_name}}/{{cookiecutter.django_default_app_name}}/tasks.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters