Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 58 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ backends are great candidates for community contributions.

## Basic Usage

Start by adding `django_lightweight_queue` to your `INSTALLED_APPS`:

```python
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
...,
"django_lightweight_queue",
]
```

After that, define your task in any file you want:

```python
import time
from django_lightweight_queue import task
Expand Down Expand Up @@ -67,12 +80,51 @@ present in the specified file are inherited from the global configuration.

There are four built-in backends:

| Backend | Type | Description |
| -------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Synchronous | Development | Executes the task inline, without any actual queuing. |
| Redis | Production | Executes tasks at-most-once using [Redis][redis] for storage of the enqueued tasks. |
| 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_. |
| 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. |
### Synchronous (Development backend)

`django_lightweight_queue.backends.synchronous.SynchronousBackend`

Executes the task inline, without any actual queuing.

### Redis (Production backend)

`django_lightweight_queue.backends.redis.RedisBackend`

Executes tasks at-most-once using [Redis][redis] for storage of the enqueued tasks.

### Reliable Redis (Production backend)

`django_lightweight_queue.backends.reliable_redis.ReliableRedisBackend`

Executes tasks at-least-once using [Redis][redis] for storage of the enqueued tasks (subject to Redis consistency). Does not guarantee the task _completes_.

### Debug Web (Debug backend)

`django_lightweight_queue.backends.debug_web.DebugWebBackend`

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.

Use this to append the appropriate URLs to the bottom of your root `urls.py`:

```python
from django.conf import settings
from django.urls import path, include

urlpatterns = [
...
]

if "debug_web" in settings.LIGHTWEIGHT_QUEUE_BACKEND:
from django_lightweight_queue import urls as dlq_urls
urlpatterns += [path("", include(dlq_urls))]
```

This backend may require an extra setting if your debug site is not on localhost:

```python
# defaults to http://localhost:8000
LIGHTWEIGHT_QUEUE_SITE_URL = "http://example.com:8000"
```

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

Expand Down