Skip to content

Commit 6ebd73a

Browse files
committed
Merge branch 'update-readme'
2 parents a6428d8 + 228d665 commit 6ebd73a

File tree

1 file changed

+64
-6
lines changed

1 file changed

+64
-6
lines changed

README.md

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ backends are great candidates for community contributions.
1515

1616
## Basic Usage
1717

18+
Start by adding `django_lightweight_queue` to your `INSTALLED_APPS`:
19+
20+
```python
21+
INSTALLED_APPS = [
22+
"django.contrib.admin",
23+
"django.contrib.auth",
24+
...,
25+
"django_lightweight_queue",
26+
]
27+
```
28+
29+
After that, define your task in any file you want:
30+
1831
```python
1932
import time
2033
from django_lightweight_queue import task
@@ -67,12 +80,57 @@ present in the specified file are inherited from the global configuration.
6780

6881
There are four built-in backends:
6982

70-
| Backend | Type | Description |
71-
| -------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
72-
| Synchronous | Development | Executes the task inline, without any actual queuing. |
73-
| Redis | Production | Executes tasks at-most-once using [Redis][redis] for storage of the enqueued tasks. |
74-
| Reliable Redis | Production | Executes tasks at-least-once using [Redis][redis] for storage of the enqueued tasks (subject to Redis consistency). Does not guarantee the task _completes_. |
75-
| Debug Web | Debugging | Instead of running jobs it prints the url to a view that can be used to run a task in a transaction which will be rolled back. This is useful for debugging and optimising tasks. |
83+
### Synchronous (Development backend)
84+
85+
`django_lightweight_queue.backends.synchronous.SynchronousBackend`
86+
87+
Executes the task inline, without any actual queuing.
88+
89+
### Redis (Production backend)
90+
91+
`django_lightweight_queue.backends.redis.RedisBackend`
92+
93+
Executes tasks at-most-once using [Redis][redis] for storage of the enqueued tasks.
94+
95+
### Reliable Redis (Production backend)
96+
97+
`django_lightweight_queue.backends.reliable_redis.ReliableRedisBackend`
98+
99+
Executes tasks at-least-once using [Redis][redis] for storage of the enqueued tasks (subject to Redis consistency). Does not guarantee the task _completes_.
100+
101+
### Debug Web (Debug backend)
102+
103+
`django_lightweight_queue.backends.debug_web.DebugWebBackend`
104+
105+
Instead of running jobs it prints the url to a view that can be used to run a task in a transaction which will be rolled back. This is useful for debugging and optimising tasks.
106+
107+
Use this to append the appropriate URLs to the bottom of your root `urls.py`:
108+
109+
```python
110+
from django.conf import settings
111+
from django.urls import path, include
112+
113+
urlpatterns = [
114+
...
115+
]
116+
117+
if settings.DEBUG:
118+
urlpatterns += [
119+
path(
120+
"",
121+
include(
122+
"django_lightweight_queue.urls", namespace="django-lightweight-queue"
123+
),
124+
)
125+
]
126+
```
127+
128+
This backend may require an extra setting if your debug site is not on localhost:
129+
130+
```python
131+
# defaults to http://localhost:8000
132+
LIGHTWEIGHT_QUEUE_SITE_URL = "http://example.com:8000"
133+
```
76134

77135
[redis]: https://redis.io/
78136

0 commit comments

Comments
 (0)