Skip to main content

Durable workflows for Django.

Project description

Django Hookflow

Durable workflows for Django, powered by Upstash QStash and Django QStash

Installation

uv add django-hookflow

or

pip install django-hookflow

Requirements:

  • Python 3.10+
  • Django 4.2+

Features

  • Durable Workflows: Multi-step workflows that survive restarts and failures

Quick Start

Define workflows with steps that automatically checkpoint their progress. If a step fails or the server restarts, the workflow resumes from where it left off.

# app/workflows.py
from django_hookflow import workflow


@workflow
def process_order(ctx):
    order_id = ctx.data.get("order_id")

    # Each step is executed exactly once, even across retries
    validated = ctx.step.run("validate", validate_order, order_id)

    # Durable sleep - doesn't consume server resources
    ctx.step.sleep("wait-for-payment", seconds=60)

    # Make HTTP calls with automatic retry and caching
    payment = ctx.step.call("charge", url="https://api.stripe.com/...", method="POST")

    result = ctx.step.run("fulfill", fulfill_order, order_id, payment)

    return {"status": "completed", "result": result}

Trigger workflows programmatically:

# Trigger returns immediately, workflow runs asynchronously
run_id = process_order.trigger(data={"order_id": "12345"})

Configuration

Add to your Django settings:

QSTASH_TOKEN = "your-qstash-token"
DJANGO_HOOKFLOW_DOMAIN = "https://your-app.com"
DJANGO_HOOKFLOW_WEBHOOK_PATH = "/hookflow/"  # optional, defaults to /hookflow/

Add the webhook URLs to your urls.py:

from django.urls import include, path

urlpatterns = [
    path("hookflow/", include("django_hookflow.urls")),
]

Workflow Context API

Inside a workflow function, ctx provides:

Property Description
ctx.data Initial payload passed to .trigger()
ctx.run_id Unique identifier for this workflow run
ctx.workflow_id The workflow's identifier
ctx.step Step manager for durable operations

Step Manager Methods

Method Description
ctx.step.run(step_id, fn, *args, **kwargs) Execute a function as a durable step
ctx.step.sleep(step_id, seconds) Sleep without consuming resources
ctx.step.call(step_id, url, method, body, headers) Make a durable HTTP request

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_hookflow-0.0.2.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

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

django_hookflow-0.0.2-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file django_hookflow-0.0.2.tar.gz.

File metadata

  • Download URL: django_hookflow-0.0.2.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_hookflow-0.0.2.tar.gz
Algorithm Hash digest
SHA256 fef276d92f29463f496dabb913307de687d8f76a0807d239094be1827e8aa587
MD5 8ca6382d9e3c1aa05a63577bc9520522
BLAKE2b-256 042fa047e2add38a0a19db6023e9ddc805066e5e63f464d31a24909b99c12715

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_hookflow-0.0.2.tar.gz:

Publisher: main.yaml on jmitchel3/django-hookflow

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_hookflow-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_hookflow-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f6e2d5ea35c903bb10af69227b6554e3bd5f8e2df7c7b71321726cad24fc5cd9
MD5 3151ba6e8006888d4ee970add290bad6
BLAKE2b-256 4f634d075cdfb1e8a112e3b6361f45a2aee85c048efdd30d73e878e76a9f8502

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_hookflow-0.0.2-py3-none-any.whl:

Publisher: main.yaml on jmitchel3/django-hookflow

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