Skip to main content

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.36.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.receive events
  • 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


Download files

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

Source Distribution

amgi_sqs_event_source_mapping-0.36.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file amgi_sqs_event_source_mapping-0.36.0.tar.gz.

File metadata

  • Download URL: amgi_sqs_event_source_mapping-0.36.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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

Hashes for amgi_sqs_event_source_mapping-0.36.0.tar.gz
Algorithm Hash digest
SHA256 5606315ba416db328234effec42d7a58b5af7a8625aa427cdda01f8653c7191a
MD5 ae62a22f8ccf52a6fed9a4bf6e9a7de3
BLAKE2b-256 fbe31d05b37c85e8563bb74e53488ec8bfe8c8f8bb170d29b285d4963d2128f1

See more details on using hashes here.

File details

Details for the file amgi_sqs_event_source_mapping-0.36.0-py3-none-any.whl.

File metadata

  • Download URL: amgi_sqs_event_source_mapping-0.36.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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

Hashes for amgi_sqs_event_source_mapping-0.36.0-py3-none-any.whl
Algorithm Hash digest
SHA256 abfacb65cd6c34d81d4f262124cb6644f1d2b3ef44fb31b96a75c6103204e907
MD5 ad42fb94d004210b0d31f093e4eca2fb
BLAKE2b-256 649f96ebb78c9ece0a01ea4088f6e701c6d21d3f94e42a31409308334c91801b

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