Metadata-Version: 2.4
Name: enqueuefy
Version: 0.0.1a1
Summary: Async task queue library for Python — Redis and AWS SQS/Lambda backends
Author: Igor
License: MIT
Keywords: async,task-queue,redis,sqs,worker,asyncio
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Framework :: AsyncIO
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.12
Description-Content-Type: text/markdown
Requires-Dist: redis>=7.2.0
Requires-Dist: watchdog>=6.0.0

# enqueuefy

Async task queue library for Python with Redis and AWS SQS/Lambda backends.

## Installation

```bash
pip install enqueuefy
```

## Quick start — Redis

**server.py** (worker process)

```python
from enqueuefy import AIORedisConsumer

consumer = AIORedisConsumer(
    broker_url="redis://localhost:6379",
    modules=["myapp.tasks"],
)

queue = consumer.queue("default")

if __name__ == "__main__":
    consumer.run()
```

**tasks.py** (define tasks)

```python
from myapp.server import queue

@queue.task(retries=3, timeout=30)
async def send_email(to: str, subject: str):
    ...

@send_email.on_failure
async def on_send_failure(to: str, subject: str):
    print(f"Failed to send email to {to}")

@send_email.on_timeout
async def on_send_timeout(to: str, subject: str):
    print(f"Email to {to} timed out")
```

**producer.py** (enqueue tasks)

```python
from myapp.tasks import send_email

await send_email.enqueue("user@example.com", subject="Hello")
```

**Run the worker**

```bash
python server.py --broker-url redis://localhost:6379 --queues default --max-concurrency 10
```

## Quick start — AWS SQS / Lambda

**server.py**

```python
from enqueuefy import AIOSQSLambdaConsumer

consumer = AIOSQSLambdaConsumer(
    region_name="us-east-1",
    aws_access_key_id="...",
    aws_secret_access_key="...",
    modules=["myapp.tasks"],
)

queue = consumer.queue("https://sqs.us-east-1.amazonaws.com/123456789/my-queue")

if __name__ == "__main__":
    consumer.run()  # generates Lambda handler files
```

**tasks.py**

```python
from myapp.server import queue

@queue.task()
async def process_order(order_id: str):
    ...
```

Running `server.py` generates ready-to-deploy AWS Lambda handler files in `sqs_lambda_handlers/`.

## CLI options (Redis worker)

| Flag | Default | Description |
|---|---|---|
| `--broker-url` | — | Redis connection URL |
| `--queues` | `default` | Comma-separated queue names |
| `--max-concurrency` | `10` | Max concurrent tasks |

## Features

- Async-first, built on `asyncio`
- Redis backend with at-least-once delivery and startup recovery of in-flight messages
- Per-task `retries`, `timeout`, `on_failure`, and `on_timeout` hooks
- SQS/Lambda backend that auto-generates Lambda handler files
- Distributed startup-requeue lock — safe for multi-pod Kubernetes deployments

## Development

```bash
make test        # run tests
make coverage    # test with coverage report
make format      # black + isort
make build       # build distribution packages
make publish     # upload to PyPI via twine
make publish-test  # upload to TestPyPI
```

## License

MIT
