AMGI SQS event source mapping handler
Project description
amgi-sqs-event-source-mapping
amgi-sqs-event-source-mapping is an adaptor for AMGI applications to run in an SQS event source mapped Lambda.
Installation
pip install amgi-sqs-event-source-mapping==0.39.0
Example
This example uses AsyncFast:
from dataclasses import dataclass
from amgi_sqs_event_source_mapping import SqsEventSourceMappingHandler
from asyncfast import AsyncFast
app = AsyncFast()
@dataclass
class Order:
item_ids: list[str]
@app.channel("order-queue")
async def order_queue(order: Order) -> None:
# Makes an order
...
handler = SqsEventSourceMappingHandler(app)
What it does
- Converts SQS batch events into AMGI
message.receiveevents - Uses the SQS queue name as the AMGI message address
- Supports partial batch failures so only failed messages are retried
- Sends outbound messages back to SQS efficiently using batching
- Optionally manages application startup and shutdown via AMGI lifespan
- Verifies message integrity using the SQS-provided MD5 checksum and retries corrupted messages
Record handling
- Record bodies are passed to your app as bytes
- SQS record attributes become AMGI headers
- Records are only acknowledged when your app emits
message.ack - Records that are not acknowledged are treated as failures and will be retried
- Corrupted messages are detected automatically and retried
Lifespan
Lifespan support is enabled by default.
- Startup runs once per Lambda execution environment
- Shutdown is attempted when the environment is terminated
Shutdown handling relies on signal.SIGTERM, which is supported by Python 3.12 and later Lambda runtimes.
To use fully stateless, per-invocation behavior, disable lifespan:
handler = SqsEventSourceMappingHandler(app, lifespan=False)
Contact
For questions or suggestions, please contact jack.burridge@mail.com.
License
Copyright 2025 AMGI
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 amgi_sqs_event_source_mapping-0.39.0.tar.gz.
File metadata
- Download URL: amgi_sqs_event_source_mapping-0.39.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
103be687b00b070131e48ce4e269661219ce0a378448882cd9fdb24be5005fab
|
|
| MD5 |
7446b6fe6009b5cb1415647e3dd0bb3f
|
|
| BLAKE2b-256 |
24d34f97ab45a0a8925bbf3facd5c35f1f955fc6310604ef79b1d1ffea34b922
|
File details
Details for the file amgi_sqs_event_source_mapping-0.39.0-py3-none-any.whl.
File metadata
- Download URL: amgi_sqs_event_source_mapping-0.39.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b737f12bdcc823b8c93660ae14e9a9fa2c0a76a988ce5748b8261717cd5f297
|
|
| MD5 |
841a8af1913eb89ffcb649133dbc15ea
|
|
| BLAKE2b-256 |
6ca10bb4b93de3a74957a8519b0f46dae57f95ce63c232567e625c9c40f6eee0
|