Skip to content

Commit b6b089f

Browse files
committed
update readme with additions related to installing and settings refactor
1 parent f6106f6 commit b6b089f

File tree

1 file changed

+58
-6
lines changed

1 file changed

+58
-6
lines changed

README.md

Lines changed: 58 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,51 @@ 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 "debug_web" in settings.LIGHTWEIGHT_QUEUE_BACKEND:
118+
from django_lightweight_queue import urls as dlq_urls
119+
urlpatterns += [path("", include(dlq_urls))]
120+
```
121+
122+
This backend may require an extra setting if your debug site is not on localhost:
123+
124+
```python
125+
# defaults to http://localhost:8000
126+
LIGHTWEIGHT_QUEUE_SITE_URL = "http://example.com:8000"
127+
```
76128

77129
[redis]: https://redis.io/
78130

0 commit comments

Comments
 (0)