Skip to main content

Async SQS routing and middleware library

Project description

fastsqs

Fast, modern, async SQS routing and middleware for Python.

PyPI version License: MIT


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(key="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)

Example Payload

{
  "type": "greeting",
  "message": "Hello from SQS!"
}

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 QueueRouter to 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


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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastsqs-0.1.3.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

fastsqs-0.1.3-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file fastsqs-0.1.3.tar.gz.

File metadata

  • Download URL: fastsqs-0.1.3.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for fastsqs-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e81d11646edada992a2b7c1c481c8fd1d9e50d184fd9766b23a7a0c90c666578
MD5 6d5e7076137aa7ffe6715c0ddc125aea
BLAKE2b-256 e70ba74d5a3b566b5b6544ecdf9c03ad865fde6840a6a16cb9a0a1ad903bba1f

See more details on using hashes here.

File details

Details for the file fastsqs-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: fastsqs-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for fastsqs-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 53da161a78ed58055316c7a99d1e134a1e4d94e96b64a8021e72b834e434282e
MD5 8f6419c515dab5f97a8c1cb029e685fd
BLAKE2b-256 c70b6b113f0394679f0d67bdf157bb608a1a0380cdceaebba34f53ce1a4fc09a

See more details on using hashes here.

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