SQS
Handler
Processes SQS messages and stores results in a DynamoDB table.
Source code in templates/sqs/handler.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
__init__(repository)
Initialize the handler with a repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repository
|
Repository
|
The repository used to store processed items. |
required |
Source code in templates/sqs/handler.py
25 26 27 28 29 30 31 | |
handle_record(record)
Handle a single SQS record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
SQSRecord
|
The SQS record to process. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the message body cannot be parsed or processed. |
Source code in templates/sqs/handler.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
main(event, context)
Lambda entry point for the SQS-to-DynamoDB handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
dict
|
The SQS event containing a batch of messages. |
required |
context
|
LambdaContext
|
The Lambda execution context. |
required |
Returns:
| Type | Description |
|---|---|
PartialItemFailureResponse
|
A partial batch response indicating which records failed processing. |
Source code in templates/sqs/handler.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |