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
Tasks routing #1487
Tasks routing #1487
Conversation
udata/search/__init__.py
Outdated
@@ -121,7 +121,7 @@ def get_i18n_analyzer(): | |||
i18n_analyzer = LocalProxy(lambda: get_i18n_analyzer()) | |||
|
|||
|
|||
@celery.task | |||
@task(queue='high', routing_key='high.search') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not route='high.search'
? To stay consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just forgot to remove the queue
. I added the route
after as a shortcut.
@@ -26,6 +29,7 @@ def __call__(self, *args, **kwargs): | |||
|
|||
class JobTask(ContextTask): | |||
abstract = True | |||
default_queue = 'low' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe default
? Because, you know, default
;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is default
for tasks, jobs are meant to be long running tasks this is why I set them to low
by default. But I can undo this, but this mean we have to declare queue=low
manually for every job
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes senses 👍
@job('test-low-queue', queue='low') | ||
@job('test-default-queue', queue='default') | ||
@job('test-high-queue', queue='high') | ||
def queue_test(self, raises=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't be defined in test files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is intentional, like log-test
and error-test
: this allow to manually run these jobs with udata job run -d test-high-queue
and see if this is properly routing.
You can also run udata job run -d test-high-queue raises=True
and you can have the time for a tasks to be processed because the exception will appear in Sentry with a timestamp.
This PR refactor the task routing: the default route can be defined at declaration time, on both
task
andjob
, by either using:queue
and/orrouting_key
parametersroute
parameter from whichqueue
androuting_key
will be computed (route=high.somewhere
givesqueue=high
androuting_key=high.somewhere
)This also allows extension to define routing on their tasks.
Some route have been added to the existing tasks and jobs.