Django tasks backend for Google Cloud Pub/Sub
Project description
django_tasks_pubsub
Google Cloud Pub/Sub backend for Django tasks
Installation
Package manager
pip
pip install django_tasks_pubsub
uv
uv add django_tasks_pubsub
Add to INSTALLED_APPS
INSTALLED_APPS = [
...
"django_tasks_pubsub",
]
Settings
Add required Google Cloud Pub/Sub settings
PUBSUB_PROJECT_ID = "your-google-cloud-project-id"
PUBSUB_DEFAULT_TOPIC_ID = "your-default-topic-id"
Add the backend to the TASKS setting
TASKS = {
"default": {
"BACKEND": "django_tasks_pubsub.PubSubBackend",
}
}
Authentication
Check out the Google Cloud Pub/Sub documentation for more information.
In short the the client works well within a Google Cloud environment.
URLs
In order to receive push messages from Google Cloud Pub/Sub, you need to register the endpoint in your project's urls.py:
from django.urls import path, include
urlpatterns = [
...
path("", include("django_tasks_pubsub.urls")),
]
This will expose the endpoint at /pubsub/push/. You should configure your Google Cloud Pub/Sub push subscription to use this endpoint (e.g. https://your-domain.com/pubsub/push/).
Usage
Configure Django task functions
from django.tasks import task
@task
def send_email(user_id):
print(f"Sending email to {user_id}")
Configure specifics for the task
Specify a topic
To specify a topic, you need to decorate the task with @task and @pubsub_task(topic="topic-name") in this order:
from django.tasks import task
from django_tasks_pubsub import pubsub_task
@task
@pubsub_task(topic="images")
def function(image_id):
...
Development
Commit Messages
All commits to this repository must follow the Conventional Commits specification.
This is required because the automated release and tagging workflow relies on conventional commit prefixes (such as feat:, fix:, chore:, docs:, etc.) to automatically calculate the next semantic version.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_tasks_pubsub-0.1.8.tar.gz.
File metadata
- Download URL: django_tasks_pubsub-0.1.8.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84b9e207cf643a09cf8dc801fe4080f38fc62c801909f21537490395bfd5cda2
|
|
| MD5 |
09ef5aca0c0f3df2b98567d9a3e7b645
|
|
| BLAKE2b-256 |
0ee00bbecd30ccc7127c858b29344f1f74717e2a7e9f49246aa78dfd07b20126
|
Provenance
The following attestation bundles were made for django_tasks_pubsub-0.1.8.tar.gz:
Publisher:
create_tag_and_release.yml on joelbitar/django_tasks_pubsub
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_tasks_pubsub-0.1.8.tar.gz -
Subject digest:
84b9e207cf643a09cf8dc801fe4080f38fc62c801909f21537490395bfd5cda2 - Sigstore transparency entry: 1575012379
- Sigstore integration time:
-
Permalink:
joelbitar/django_tasks_pubsub@ad0d01d4eb661c9a942e6e50f55f4f5edf536184 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/joelbitar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
create_tag_and_release.yml@ad0d01d4eb661c9a942e6e50f55f4f5edf536184 -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_tasks_pubsub-0.1.8-py3-none-any.whl.
File metadata
- Download URL: django_tasks_pubsub-0.1.8-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54d5d9a2520aa1769613fd21863e96ec2a0210c842f8b5946aaf5c6307e7df92
|
|
| MD5 |
b3ad0e999be76024e8514e28ed9794c8
|
|
| BLAKE2b-256 |
54de2b19270ea1fdd526a85bd3ffd5d55158a9e4e6f7cc61002aafb01e420fc8
|
Provenance
The following attestation bundles were made for django_tasks_pubsub-0.1.8-py3-none-any.whl:
Publisher:
create_tag_and_release.yml on joelbitar/django_tasks_pubsub
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_tasks_pubsub-0.1.8-py3-none-any.whl -
Subject digest:
54d5d9a2520aa1769613fd21863e96ec2a0210c842f8b5946aaf5c6307e7df92 - Sigstore transparency entry: 1575012420
- Sigstore integration time:
-
Permalink:
joelbitar/django_tasks_pubsub@ad0d01d4eb661c9a942e6e50f55f4f5edf536184 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/joelbitar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
create_tag_and_release.yml@ad0d01d4eb661c9a942e6e50f55f4f5edf536184 -
Trigger Event:
push
-
Statement type: