You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/utilities/batch.md
+12-16
Original file line number
Diff line number
Diff line change
@@ -219,12 +219,11 @@ The remaining sections of the documentation will rely on these samples. For comp
219
219
220
220
### Processing messages from SQS
221
221
222
-
Processing batches from SQS works in four stages:
222
+
Processing batches from SQS works in three stages:
223
223
224
224
1. Instantiate **`BatchProcessor`** and choose **`EventType.SQS`** for the event type
225
225
2. Define your function to handle each batch record, and use [`SQSRecord`](data_classes.md#sqs){target="_blank"} type annotation for autocompletion
226
-
3. Use either **`batch_processor`** decorator or your instantiated processor as a context manager to kick off processing
227
-
4. Return the appropriate response contract to Lambda via **`.response()`** processor method
226
+
3. Use **`process_partial_response`** to kick off processing
228
227
229
228
???+ info
230
229
This code example optionally uses Tracer and Logger for completion.
@@ -241,7 +240,7 @@ Processing batches from SQS works in four stages:
241
240
import json
242
241
243
242
from aws_lambda_powertools import Logger, Tracer
244
-
from aws_lambda_powertools.utilities.batch import BatchProcessor, EventType, batch_processor
243
+
from aws_lambda_powertools.utilities.batch import BatchProcessor, EventType
245
244
from aws_lambda_powertools.utilities.data_classes.sqs_event import SQSRecord
246
245
from aws_lambda_powertools.utilities.typing import LambdaContext
247
246
@@ -378,12 +377,11 @@ This helps preserve the ordering of messages in your queue.
378
377
379
378
### Processing messages from Kinesis
380
379
381
-
Processing batches from Kinesis works in four stages:
380
+
Processing batches from Kinesis works in three stages:
382
381
383
382
1. Instantiate **`BatchProcessor`** and choose **`EventType.KinesisDataStreams`** for the event type
384
383
2. Define your function to handle each batch record, and use [`KinesisStreamRecord`](data_classes.md#kinesis-streams){target="_blank"} type annotation for autocompletion
385
-
3. Use either **`batch_processor`** decorator or your instantiated processor as a context manager to kick off processing
386
-
4. Return the appropriate response contract to Lambda via **`.response()`** processor method
384
+
3. Use **`process_partial_response`** to kick off processing
387
385
388
386
???+ info
389
387
This code example optionally uses Tracer and Logger for completion.
@@ -400,7 +398,7 @@ Processing batches from Kinesis works in four stages:
400
398
import json
401
399
402
400
from aws_lambda_powertools import Logger, Tracer
403
-
from aws_lambda_powertools.utilities.batch import BatchProcessor, EventType, batch_processor
401
+
from aws_lambda_powertools.utilities.batch import BatchProcessor, EventType
404
402
from aws_lambda_powertools.utilities.data_classes.kinesis_stream_event import KinesisStreamRecord
405
403
from aws_lambda_powertools.utilities.typing import LambdaContext
406
404
@@ -510,12 +508,11 @@ Processing batches from Kinesis works in four stages:
510
508
511
509
### Processing messages from DynamoDB
512
510
513
-
Processing batches from Kinesis works in four stages:
511
+
Processing batches from Kinesis works in three stages:
514
512
515
513
1. Instantiate **`BatchProcessor`** and choose **`EventType.DynamoDBStreams`** for the event type
516
514
2. Define your function to handle each batch record, and use [`DynamoDBRecord`](data_classes.md#dynamodb-streams){target="_blank"} type annotation for autocompletion
517
-
3. Use either **`batch_processor`** decorator or your instantiated processor as a context manager to kick off processing
518
-
4. Return the appropriate response contract to Lambda via **`.response()`** processor method
515
+
3. Use **`process_partial_response`** to kick off processing
519
516
520
517
???+ info
521
518
This code example optionally uses Tracer and Logger for completion.
@@ -532,7 +529,7 @@ Processing batches from Kinesis works in four stages:
532
529
import json
533
530
534
531
from aws_lambda_powertools import Logger, Tracer
535
-
from aws_lambda_powertools.utilities.batch import BatchProcessor, EventType, batch_processor
532
+
from aws_lambda_powertools.utilities.batch import BatchProcessor, EventType
536
533
from aws_lambda_powertools.utilities.data_classes.dynamo_db_stream_event import DynamoDBRecord
537
534
from aws_lambda_powertools.utilities.typing import LambdaContext
538
535
@@ -673,7 +670,7 @@ All records in the batch will be passed to this handler for processing, even if
673
670
674
671
!!! tip "New to AsyncIO? Read this [comprehensive guide first](https://realpython.com/async-io-python/){target="_blank"}."
675
672
676
-
You can use `AsyncBatchProcessor` class and `async_batch_processor` decorator to process messages concurrently.
673
+
You can use `AsyncBatchProcessor` class and `async_process_partial_response` function to process messages concurrently.
677
674
678
675
???+ question "When is this useful?"
679
676
Your use case might be able to process multiple records at the same time without conflicting with one another.
@@ -845,7 +842,7 @@ Use the context manager to access a list of all returned values from your `recor
845
842
***When successful**. We will include a tuple with `success`, the result of `record_handler`, and the batch record
846
843
***When failed**. We will include a tuple with `fail`, exception as a string, and the batch record
847
844
848
-
```python hl_lines="31-38" title="Accessing processed messages via context manager"
845
+
```python hl_lines="30-36" title="Accessing processed messages via context manager"
849
846
import json
850
847
851
848
from typing import Any, List, Literal, Union
@@ -854,8 +851,7 @@ from aws_lambda_powertools import Logger, Tracer
854
851
from aws_lambda_powertools.utilities.batch import (BatchProcessor,
855
852
EventType,
856
853
FailureResponse,
857
-
SuccessResponse,
858
-
batch_processor)
854
+
SuccessResponse)
859
855
from aws_lambda_powertools.utilities.data_classes.sqs_event import SQSRecord
860
856
from aws_lambda_powertools.utilities.typing import LambdaContext
0 commit comments