Skip to main content

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",
    }
}

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

django_tasks_pubsub-0.1.7.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_tasks_pubsub-0.1.7-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file django_tasks_pubsub-0.1.7.tar.gz.

File metadata

  • Download URL: django_tasks_pubsub-0.1.7.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_tasks_pubsub-0.1.7.tar.gz
Algorithm Hash digest
SHA256 8a33ebc950729aef0eae2fd3086b67e25e2e9ba7e8884a17da6526a0bacca772
MD5 11efbbe5e7d53587645b8b4077eb28d7
BLAKE2b-256 a5e98182d7bb0982df0df5b0544c62093795d020f53af782125e7f6443f6f87f

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_tasks_pubsub-0.1.7.tar.gz:

Publisher: create_tag_and_release.yml on joelbitar/django_tasks_pubsub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_tasks_pubsub-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for django_tasks_pubsub-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 3aaa8a04ecf2c6105c5a55ce1cf0629f01eddae87d109b77d444d7fbfee90b11
MD5 f8e6878b53bea6e9fade6385984bb050
BLAKE2b-256 eb49a0c9c558220189e57a3526b62e5a84efff8aa537607d114f05b45cbd721f

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_tasks_pubsub-0.1.7-py3-none-any.whl:

Publisher: create_tag_and_release.yml on joelbitar/django_tasks_pubsub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page