Metadata-Version: 2.4
Name: elephantq
Version: 0.3.0
Summary: ElephantQ - PostgreSQL-only async job queue - built for developer happiness.
Author-email: Abhinav Saxena <abhinav@apiclabs.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/abhinavs/elephantq
Project-URL: Repository, https://github.com/abhinavs/elephantq
Project-URL: Documentation, https://github.com/abhinavs/elephantq/tree/main/docs
Project-URL: Changelog, https://github.com/abhinavs/elephantq/blob/main/CHANGELOG.md
Project-URL: Bug Tracker, https://github.com/abhinavs/elephantq/issues
Keywords: async,job,queue,postgresql,task,redis-alternative,developer-experience,background-jobs
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Distributed Computing
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: asyncpg<0.32.0,>=0.30.0
Requires-Dist: pydantic<3.0.0,>=2.7.1
Requires-Dist: pydantic-settings<3.0.0,>=2.0.0
Provides-Extra: scheduling
Requires-Dist: croniter>=1.4.0; extra == "scheduling"
Provides-Extra: sqlite
Requires-Dist: aiosqlite>=0.19.0; extra == "sqlite"
Provides-Extra: webhooks
Requires-Dist: aiohttp>=3.8.0; extra == "webhooks"
Requires-Dist: cryptography>=3.4.0; extra == "webhooks"
Provides-Extra: logging
Requires-Dist: structlog>=22.0.0; extra == "logging"
Provides-Extra: dev
Requires-Dist: pytest>=7.4.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: httpx>=0.24.0; extra == "dev"
Requires-Dist: black==25.1.0; extra == "dev"
Requires-Dist: flake8==7.1.0; extra == "dev"
Requires-Dist: isort==6.0.1; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Requires-Dist: pre-commit>=3.4.0; extra == "dev"
Requires-Dist: croniter>=1.4.0; extra == "dev"
Requires-Dist: aiohttp>=3.8.0; extra == "dev"
Requires-Dist: aiosqlite>=0.19.0; extra == "dev"
Requires-Dist: structlog>=22.0.0; extra == "dev"
Requires-Dist: cryptography>=3.4.0; extra == "dev"
Provides-Extra: dashboard
Requires-Dist: fastapi>=0.100.0; extra == "dashboard"
Requires-Dist: uvicorn>=0.20.0; extra == "dashboard"
Provides-Extra: monitoring
Requires-Dist: prometheus-client>=0.15.0; extra == "monitoring"
Requires-Dist: psutil>=5.9.0; extra == "monitoring"
Provides-Extra: full
Requires-Dist: elephantq[dashboard,logging,monitoring,scheduling,sqlite,webhooks]; extra == "full"
Dynamic: license-file

# ElephantQ

Background jobs for Python. Powered by the Postgres you already have.

[![PyPI version](https://img.shields.io/pypi/v/elephantq)](https://pypi.org/project/elephantq/)
[![Python versions](https://img.shields.io/pypi/pyversions/elephantq)](https://pypi.org/project/elephantq/)
[![License](https://img.shields.io/github/license/abhinavs/elephantq)](https://github.com/abhinavs/elephantq/blob/main/LICENSE)
[![Tests](https://img.shields.io/github/actions/workflow/status/abhinavs/elephantq/tests.yml?label=tests)](https://github.com/abhinavs/elephantq/actions)

## Quickstart

```bash
pip install elephantq
```

```python
# jobs.py
from elephantq import ElephantQ

app = ElephantQ(database_url="postgresql://localhost/myapp")

@app.job(max_retries=3)
async def send_welcome(to: str):
    print(f"Sending welcome email to {to}")
```

```python
# enqueue from anywhere in your app
await app.enqueue(send_welcome, to="dev@example.com")
```

```bash
# set up tables and start processing
elephantq setup
elephantq start --concurrency 4
```

Four steps. Define a job, enqueue it, set up the database, start a worker.

> **Local dev without Postgres?** Use SQLite: `ElephantQ(database_url='local.db')`.
> For production, always use PostgreSQL.

## Transactional enqueue

Enqueue a job inside your database transaction. If the transaction rolls back, the job never existed.

```python
async with pool.acquire() as conn:
    async with conn.transaction():
        await conn.execute("INSERT INTO orders ...")
        await app.enqueue(send_invoice, connection=conn, order_id=order_id)
        # Both commit together, or neither does
```

No Redis queue can do this. Your job and your data land in the same commit. If something fails halfway through, both roll back. No stale jobs, no ghost tasks, no cleanup scripts.

## Why ElephantQ

Most Python job queues force you to run Redis or RabbitMQ alongside your database. That's another service to deploy, monitor, back up, and debug when things go wrong at 3am.

ElephantQ uses your existing PostgreSQL. One dependency. One place your data lives. One thing to back up.

| Feature             | ElephantQ | Celery         | RQ     |
| ------------------- | --------- | -------------- | ------ |
| No Redis dependency | Yes       | No             | No     |
| Async native        | Yes       | Partial        | No     |
| Transactional enq.  | Yes       | No             | No     |
| Setup complexity    | Low       | High           | Medium |
| Built-in dashboard  | Yes       | No (Flower)    | No     |
| Dead-letter queue   | Yes       | No             | No     |

## Features

- **Retries with backoff** -- configurable delays, exponential backoff, per-attempt delay lists
- **Dead-letter queue** -- failed jobs preserved for inspection and manual retry
- **Job priorities** -- lower number = higher priority, processed first
- **Scheduled jobs** -- run at a specific time or after a delay
- **Recurring jobs** -- cron-based periodic tasks with `@app.periodic(cron="0 * * * *")`
- **Transactional enqueue** -- atomic with your database writes
- **Multiple queues** -- route jobs by type, run dedicated workers per queue
- **Middleware hooks** -- `before_job`, `after_job`, `on_error` for logging, metrics, tracing
- **Worker heartbeat** -- auto-detect crashed workers, requeue their jobs
- **Job results** -- store and retrieve return values from completed jobs
- **Deduplication** -- prevent duplicate jobs with `dedup_key` or `unique=True`
- **CLI** -- `setup`, `start`, `status`, `workers`, dead-letter management
- **Dashboard** -- web UI for monitoring queues, workers, and job state

## Dashboard

Monitor queues, workers, retries, and system health from a built-in web UI.

```bash
pip install elephantq[dashboard]
elephantq dashboard
```

![ElephantQ Dashboard](https://raw.githubusercontent.com/abhinavs/elephantq/main/docs/assets/elephantq_dashboard.png)

## Install

```bash
pip install elephantq              # core (Postgres backend)
pip install elephantq[full]        # everything below
pip install elephantq[sqlite]      # SQLite backend for local dev
pip install elephantq[scheduling]  # cron-based recurring jobs
pip install elephantq[dashboard]   # web dashboard
pip install elephantq[monitoring]  # Prometheus metrics
pip install elephantq[webhooks]    # webhook delivery + signing
```

## When NOT to use ElephantQ

- **You need 10k+ jobs/sec sustained throughput.** PostgreSQL row locking has limits. Redis-backed queues like Celery or Arq are built for this.
- **You need cross-language consumers.** ElephantQ is Python-only. If your workers are in Go or Node, use RabbitMQ or a similar broker.
- **You're not using PostgreSQL.** The production backend requires PostgreSQL. If your stack is MySQL or MongoDB, this isn't for you.
- **You need DAG-based workflow orchestration.** ElephantQ handles individual jobs, not pipelines. Look at Prefect or Airflow.

## Documentation

- [Quickstart](docs/getting-started/quickstart.md)
- [FastAPI integration](docs/guides/fastapi.md)
- [Jobs and concepts](docs/concepts/jobs.md)
- [Production checklist](docs/production/checklist.md)
- [Deployment](docs/production/deployment.md)
- [CLI reference](docs/cli/commands.md)
- [API reference](docs/api/elephantq.md)

## License

MIT
