Skip to content

chore(docs): update batch docs highlight & links #2320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions docs/snippets/batch/gettingStartedAsync.ts

This file was deleted.

13 changes: 6 additions & 7 deletions docs/utilities/batch.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,11 @@ For these scenarios, you can subclass `BatchProcessor` and quickly override `suc
* **`successHandler()`** – Keeps track of successful batch records
* **`failureHandler()`** – Keeps track of failed batch records

???+ example
Let's suppose you'd like to add a metric named `BatchRecordFailures` for each batch record that failed processing

```typescript hl_lines="17 21 25 31 35" title="Extending failure handling mechanism in BatchProcessor"
--8<-- "docs/snippets/batch/extendingFailure.ts"
```
Let's suppose you'd like to add a metric named `BatchRecordFailures` for each batch record that failed processing

```typescript hl_lines="3 20 24 31 37" title="Extending failure handling mechanism in BatchProcessor"
--8<-- "docs/snippets/batch/extendingFailure.ts"
```

### Create your own partial processor

Expand Down Expand Up @@ -463,7 +462,7 @@ classDiagram

You can then use this class as a context manager, or pass it to `processPartialResponseSync` to process the records in your Lambda handler function.

```typescript hl_lines="21 30 41 62 73 84" title="Creating a custom batch processor"
```typescript hl_lines="21 35 56 61 73 86" title="Creating a custom batch processor"
--8<-- "docs/snippets/batch/customPartialProcessor.ts"
```

Expand Down
9 changes: 3 additions & 6 deletions packages/batch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ import {
EventType,
processPartialResponse,
} from '@aws-lambda-powertools/batch';
import axios from 'axios'; // axios is an external dependency
import type {
SQSEvent,
SQSRecord,
Expand All @@ -188,8 +187,8 @@ import type {
const processor = new BatchProcessor(EventType.SQS);

const recordHandler = async (record: SQSRecord): Promise<number> => {
const res = await axios.post('https://httpbin.org/anything', {
message: record.body,
const res = await fetch('https://httpbin.org/anything', {
body: JSON.stringify({ message: record.body }),
});

return res.status;
Expand All @@ -207,8 +206,6 @@ export const handler = async (

Check the [docs](https://docs.powertools.aws.dev/lambda/typescript/latest/utilities/batch/) for more examples.



## Contribute

If you are interested in contributing to this project, please refer to our [Contributing Guidelines](https://github.com/aws-powertools/powertools-lambda-typescript/blob/main/CONTRIBUTING.md).
Expand Down Expand Up @@ -249,7 +246,7 @@ Share what you did with Powertools for AWS Lambda (TypeScript) 💞💞. Blog po

### Using Lambda Layer

This helps us understand who uses Powertools for AWS Lambda (TypeScript) in a non-intrusive way, and helps us gain future investments for other Powertools for AWS Lambda languages. When [using Layers](#lambda-layers), you can add Powertools as a dev dependency (or as part of your virtual env) to not impact the development process.
This helps us understand who uses Powertools for AWS Lambda (TypeScript) in a non-intrusive way, and helps us gain future investments for other Powertools for AWS Lambda languages. When [using Layers](https://docs.powertools.aws.dev/lambda/typescript/latest/#lambda-layer), you can add Powertools as a dev dependency (or as part of your virtual env) to not impact the development process.

## Credits

Expand Down