Skip to content

Update Readme #65

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

Merged
merged 2 commits into from
Jul 21, 2022
Merged
Changes from all commits
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
70 changes: 64 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,57 @@ 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 settings.DEBUG:
urlpatterns += [
path(
"",
include(
"django_lightweight_queue.urls", namespace="django-lightweight-queue"
),
)
]
```

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