Async SQS routing and middleware library
Project description
fastsqs
Fast, modern, async SQS routing and middleware for Python.
Key Features
- 🚀 High Performance: Async message routing for AWS SQS, designed for speed and scalability.
- 🧩 Declarative Routing: Organize your SQS message handling with nested routers and decorators.
- 🔒 Validation: Per-route payload validation using Pydantic models.
- 🛠️ Middleware: Add before/after hooks for logging, timing, masking, and more.
- 🦾 Partial Batch Failure: Native support for AWS Lambda batch failure responses.
- 🐍 Pythonic & Intuitive: Type hints, editor support, and a familiar API for Python developers.
Requirements
- Python 3.8+
- Pydantic (installed automatically)
Installation
pip install fastsqs
Example
Create your app
from fastsqs import QueueApp, QueueRouter, Middleware
from pydantic import BaseModel
class GreetingPayload(BaseModel):
type: str
message: str
router = QueueRouter("type")
@router.route("greeting", model=GreetingPayload)
async def handle_greeting(payload, record, context, ctx, data):
print(f"Greeting: {data.message}")
app = QueueApp(title="Greeting SQS App", debug=True)
app.include_router(router)
def lambda_handler(event, context):
return app.handler(event, context)
Add Middleware
class PrintMiddleware(Middleware):
async def before(self, payload, record, context, ctx):
print("Before:", payload)
async def after(self, payload, record, context, ctx, error):
print("After:", payload, "Error:", error)
app.add_middleware(PrintMiddleware())
How it Works
- Routing: Use
QueueRouterto route messages by payload fields. Decorators make it easy to register handlers. - Validation: Attach Pydantic models to routes for automatic payload validation.
- Middleware: Add global or per-route middleware for logging, timing, masking, etc.
- Batch Failure: Handles partial failures for SQS-triggered Lambda functions, so only failed messages are retried.
Documentation
- API Reference (coming soon)
- Tutorials (coming soon)
- Examples (see
examples/)
Contributing
Contributions, issues, and feature requests are welcome!
Please open an issue or submit a pull request.
License
This project is licensed under the terms of the MIT license.
Ready to build async, robust SQS message processors? Try fastsqs today!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastsqs-0.1.2.tar.gz.
File metadata
- Download URL: fastsqs-0.1.2.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a41a9f5ed1bf7d9ff45bbbed87cf54c32b1ed1f75c967a8abdb04ef04676a37
|
|
| MD5 |
9be144e644ba420edb1c7f1bb6e2e129
|
|
| BLAKE2b-256 |
4b55db555a477bbaf9fcf5176d4c3d65138d2a998f7b5c6c67c4b566bdb8ad35
|
File details
Details for the file fastsqs-0.1.2-py3-none-any.whl.
File metadata
- Download URL: fastsqs-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1ec85b746affb8f7ee5f510ac25c1679ace328c3cc7aec671be552597320bfb
|
|
| MD5 |
10c7e9503b6e1513dd69f235def9fa00
|
|
| BLAKE2b-256 |
d2eeb46e1672ed9840208481aae833b19d5791b9bf0c5ab6ac0d2def9b63aa1d
|