mirror of
https://github.com/HackSoftware/Django-Styleguide.git
synced 2025-02-27 08:50:36 +03:00
Add initial section for Celery
This commit is contained in:
parent
ed6bb5a5df
commit
c679538eb5
24
README.md
24
README.md
|
@ -940,6 +940,30 @@ class GetItemsForUserTests(TestCase):
|
||||||
self.assertEqual(expected, result)
|
self.assertEqual(expected, result)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Celery
|
||||||
|
|
||||||
|
We use Celery for the following general cases:
|
||||||
|
|
||||||
|
* Communicating with 3rd party services (sending emails, notifications, etc.)
|
||||||
|
* Offloading heavier computational tasks outside the HTTP cycle.
|
||||||
|
* Periodic tasks (using Celery beat)
|
||||||
|
|
||||||
|
We try to treat Celery as if it's just another interface to our core logic - meaning - **don't put business logic there.**
|
||||||
|
|
||||||
|
An exmaple task might look like this:
|
||||||
|
|
||||||
|
```python
|
||||||
|
from celery import shared_task
|
||||||
|
|
||||||
|
from project.app.services import some_service_name as service
|
||||||
|
|
||||||
|
@shared_task
|
||||||
|
def some_service_name(*args, **kwargs):
|
||||||
|
service(*args, **kwargs)
|
||||||
|
```
|
||||||
|
|
||||||
|
This is a task, having the same name as a service, which holds the actual business logic.
|
||||||
|
|
||||||
## Inspiration
|
## Inspiration
|
||||||
|
|
||||||
The way we do Django is inspired by the following things:
|
The way we do Django is inspired by the following things:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user