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

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.5.tar.gz (7.5 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.5-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_tasks_pubsub-0.1.5.tar.gz
  • Upload date:
  • Size: 7.5 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.5.tar.gz
Algorithm Hash digest
SHA256 9d8f6a6258457afd3ff0a35b9178c1e0082f4c12a7c9c7d9590e7f37c521ed74
MD5 ae51f9f5ade00a4826b8e5d5ebac0aac
BLAKE2b-256 ed61dc82eab4d8f92d2ca0cf6bf832562ccd9d18ea4ef05b3ffeef30f3a0a889

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_tasks_pubsub-0.1.5.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.5-py3-none-any.whl.

File metadata

File hashes

Hashes for django_tasks_pubsub-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 dba43a94f9faf60eac83c4db5af7930a8d1d68c510b32342284813d335a97105
MD5 a70c0b5deaf8e77f738e577de7598e61
BLAKE2b-256 705f7dbb2cc2c0bddf41d484c20714578d2d8652a407f816d45401cdd53c44d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_tasks_pubsub-0.1.5-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